Skip to content

Commit e087437

Browse files
committed
Merge tag 'xarray-6.0' of git://git.infradead.org/users/willy/xarray
Pull XArray/IDR updates from Matthew Wilcox: - Add appropriate might_alloc() annotations to the XArray APIs - Document that the IDR is deprecated * tag 'xarray-6.0' of git://git.infradead.org/users/willy/xarray: IDR: Note that the IDR API is deprecated XArray: Add calls to might_alloc()
2 parents b6bb70f + 85656ec commit e087437

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Documentation/core-api/idr.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ solution to the problem to avoid everybody inventing their own. The IDR
1717
provides the ability to map an ID to a pointer, while the IDA provides
1818
only ID allocation, and as a result is much more memory-efficient.
1919

20+
The IDR interface is deprecated; please use the :doc:`XArray <xarray>`
21+
instead.
22+
2023
IDR usage
2124
=========
2225

include/linux/xarray.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/kconfig.h>
1717
#include <linux/kernel.h>
1818
#include <linux/rcupdate.h>
19+
#include <linux/sched/mm.h>
1920
#include <linux/spinlock.h>
2021
#include <linux/types.h>
2122

@@ -586,6 +587,7 @@ static inline void *xa_store_bh(struct xarray *xa, unsigned long index,
586587
{
587588
void *curr;
588589

590+
might_alloc(gfp);
589591
xa_lock_bh(xa);
590592
curr = __xa_store(xa, index, entry, gfp);
591593
xa_unlock_bh(xa);
@@ -612,6 +614,7 @@ static inline void *xa_store_irq(struct xarray *xa, unsigned long index,
612614
{
613615
void *curr;
614616

617+
might_alloc(gfp);
615618
xa_lock_irq(xa);
616619
curr = __xa_store(xa, index, entry, gfp);
617620
xa_unlock_irq(xa);
@@ -687,6 +690,7 @@ static inline void *xa_cmpxchg(struct xarray *xa, unsigned long index,
687690
{
688691
void *curr;
689692

693+
might_alloc(gfp);
690694
xa_lock(xa);
691695
curr = __xa_cmpxchg(xa, index, old, entry, gfp);
692696
xa_unlock(xa);
@@ -714,6 +718,7 @@ static inline void *xa_cmpxchg_bh(struct xarray *xa, unsigned long index,
714718
{
715719
void *curr;
716720

721+
might_alloc(gfp);
717722
xa_lock_bh(xa);
718723
curr = __xa_cmpxchg(xa, index, old, entry, gfp);
719724
xa_unlock_bh(xa);
@@ -741,6 +746,7 @@ static inline void *xa_cmpxchg_irq(struct xarray *xa, unsigned long index,
741746
{
742747
void *curr;
743748

749+
might_alloc(gfp);
744750
xa_lock_irq(xa);
745751
curr = __xa_cmpxchg(xa, index, old, entry, gfp);
746752
xa_unlock_irq(xa);
@@ -770,6 +776,7 @@ static inline int __must_check xa_insert(struct xarray *xa,
770776
{
771777
int err;
772778

779+
might_alloc(gfp);
773780
xa_lock(xa);
774781
err = __xa_insert(xa, index, entry, gfp);
775782
xa_unlock(xa);
@@ -799,6 +806,7 @@ static inline int __must_check xa_insert_bh(struct xarray *xa,
799806
{
800807
int err;
801808

809+
might_alloc(gfp);
802810
xa_lock_bh(xa);
803811
err = __xa_insert(xa, index, entry, gfp);
804812
xa_unlock_bh(xa);
@@ -828,6 +836,7 @@ static inline int __must_check xa_insert_irq(struct xarray *xa,
828836
{
829837
int err;
830838

839+
might_alloc(gfp);
831840
xa_lock_irq(xa);
832841
err = __xa_insert(xa, index, entry, gfp);
833842
xa_unlock_irq(xa);
@@ -857,6 +866,7 @@ static inline __must_check int xa_alloc(struct xarray *xa, u32 *id,
857866
{
858867
int err;
859868

869+
might_alloc(gfp);
860870
xa_lock(xa);
861871
err = __xa_alloc(xa, id, entry, limit, gfp);
862872
xa_unlock(xa);
@@ -886,6 +896,7 @@ static inline int __must_check xa_alloc_bh(struct xarray *xa, u32 *id,
886896
{
887897
int err;
888898

899+
might_alloc(gfp);
889900
xa_lock_bh(xa);
890901
err = __xa_alloc(xa, id, entry, limit, gfp);
891902
xa_unlock_bh(xa);
@@ -915,6 +926,7 @@ static inline int __must_check xa_alloc_irq(struct xarray *xa, u32 *id,
915926
{
916927
int err;
917928

929+
might_alloc(gfp);
918930
xa_lock_irq(xa);
919931
err = __xa_alloc(xa, id, entry, limit, gfp);
920932
xa_unlock_irq(xa);
@@ -948,6 +960,7 @@ static inline int xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry,
948960
{
949961
int err;
950962

963+
might_alloc(gfp);
951964
xa_lock(xa);
952965
err = __xa_alloc_cyclic(xa, id, entry, limit, next, gfp);
953966
xa_unlock(xa);
@@ -981,6 +994,7 @@ static inline int xa_alloc_cyclic_bh(struct xarray *xa, u32 *id, void *entry,
981994
{
982995
int err;
983996

997+
might_alloc(gfp);
984998
xa_lock_bh(xa);
985999
err = __xa_alloc_cyclic(xa, id, entry, limit, next, gfp);
9861000
xa_unlock_bh(xa);
@@ -1014,6 +1028,7 @@ static inline int xa_alloc_cyclic_irq(struct xarray *xa, u32 *id, void *entry,
10141028
{
10151029
int err;
10161030

1031+
might_alloc(gfp);
10171032
xa_lock_irq(xa);
10181033
err = __xa_alloc_cyclic(xa, id, entry, limit, next, gfp);
10191034
xa_unlock_irq(xa);

tools/include/linux/sched/mm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#ifndef _TOOLS_PERF_LINUX_SCHED_MM_H
22
#define _TOOLS_PERF_LINUX_SCHED_MM_H
33

4+
#define might_alloc(gfp) do { } while (0)
5+
46
#endif /* _TOOLS_PERF_LINUX_SCHED_MM_H */

0 commit comments

Comments
 (0)