* [PATCH v1 0/2] devres: clean up and move percpu allocator
@ 2025-11-11 14:39 Andy Shevchenko
2025-11-11 14:39 ` [PATCH v1 1/2] devres: Remove unused devm_free_percpu() Andy Shevchenko
2025-11-11 14:39 ` [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h Andy Shevchenko
0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-11-11 14:39 UTC (permalink / raw)
To: Andy Shevchenko, Philipp Stanner, Greg Kroah-Hartman, linux-doc,
linux-kernel
Cc: Jonathan Corbet, Rafael J. Wysocki, Danilo Krummrich
Clean up and move managed percpu allocator to devres.h.
Andy Shevchenko (2):
devres: Remove unused devm_free_percpu()
devres: Move devm_alloc_percpu() and related to devres.h
.../driver-api/driver-model/devres.rst | 1 -
drivers/base/devres.c | 25 -------------------
include/linux/device.h | 19 --------------
include/linux/device/devres.h | 16 ++++++++++++
4 files changed, 16 insertions(+), 45 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/2] devres: Remove unused devm_free_percpu()
2025-11-11 14:39 [PATCH v1 0/2] devres: clean up and move percpu allocator Andy Shevchenko
@ 2025-11-11 14:39 ` Andy Shevchenko
2025-11-11 14:58 ` Philipp Stanner
2025-11-11 14:39 ` [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-11-11 14:39 UTC (permalink / raw)
To: Andy Shevchenko, Philipp Stanner, Greg Kroah-Hartman, linux-doc,
linux-kernel
Cc: Jonathan Corbet, Rafael J. Wysocki, Danilo Krummrich
Remove unused devm_free_percpu().
By the way, it was never used in the drivers/ from day 1.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
.../driver-api/driver-model/devres.rst | 1 -
drivers/base/devres.c | 25 -------------------
include/linux/device.h | 1 -
3 files changed, 27 deletions(-)
diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
index 2b36ebde9cec..0198ac65e874 100644
--- a/Documentation/driver-api/driver-model/devres.rst
+++ b/Documentation/driver-api/driver-model/devres.rst
@@ -383,7 +383,6 @@ NET
PER-CPU MEM
devm_alloc_percpu()
- devm_free_percpu()
PCI
devm_pci_alloc_host_bridge() : managed PCI host bridge allocation
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index c948c88d3956..f54db6d138ab 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -1222,13 +1222,6 @@ static void devm_percpu_release(struct device *dev, void *pdata)
free_percpu(p);
}
-static int devm_percpu_match(struct device *dev, void *data, void *p)
-{
- struct devres *devr = container_of(data, struct devres, data);
-
- return *(void **)devr->data == p;
-}
-
/**
* __devm_alloc_percpu - Resource-managed alloc_percpu
* @dev: Device to allocate per-cpu memory for
@@ -1264,21 +1257,3 @@ void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
return pcpu;
}
EXPORT_SYMBOL_GPL(__devm_alloc_percpu);
-
-/**
- * devm_free_percpu - Resource-managed free_percpu
- * @dev: Device this memory belongs to
- * @pdata: Per-cpu memory to free
- *
- * Free memory allocated with devm_alloc_percpu().
- */
-void devm_free_percpu(struct device *dev, void __percpu *pdata)
-{
- /*
- * Use devres_release() to prevent memory leakage as
- * devm_free_pages() does.
- */
- WARN_ON(devres_release(dev, devm_percpu_release, devm_percpu_match,
- (void *)(__force unsigned long)pdata));
-}
-EXPORT_SYMBOL_GPL(devm_free_percpu);
diff --git a/include/linux/device.h b/include/linux/device.h
index b031ff71a5bd..0c6377f6631c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -298,7 +298,6 @@ void device_remove_bin_file(struct device *dev,
void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
size_t align);
-void devm_free_percpu(struct device *dev, void __percpu *pdata);
struct device_dma_parameters {
/*
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h
2025-11-11 14:39 [PATCH v1 0/2] devres: clean up and move percpu allocator Andy Shevchenko
2025-11-11 14:39 ` [PATCH v1 1/2] devres: Remove unused devm_free_percpu() Andy Shevchenko
@ 2025-11-11 14:39 ` Andy Shevchenko
2025-11-11 16:33 ` kernel test robot
2025-11-13 4:49 ` kernel test robot
1 sibling, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-11-11 14:39 UTC (permalink / raw)
To: Andy Shevchenko, Philipp Stanner, Greg Kroah-Hartman, linux-doc,
linux-kernel
Cc: Jonathan Corbet, Rafael J. Wysocki, Danilo Krummrich
Move devm_alloc_percpu() and related to devres.h where it belongs,
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/device.h | 18 ------------------
include/linux/device/devres.h | 16 ++++++++++++++++
2 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index 0c6377f6631c..0be95294b6e6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -281,24 +281,6 @@ int __must_check device_create_bin_file(struct device *dev,
void device_remove_bin_file(struct device *dev,
const struct bin_attribute *attr);
-/**
- * devm_alloc_percpu - Resource-managed alloc_percpu
- * @dev: Device to allocate per-cpu memory for
- * @type: Type to allocate per-cpu memory for
- *
- * Managed alloc_percpu. Per-cpu memory allocated with this function is
- * automatically freed on driver detach.
- *
- * RETURNS:
- * Pointer to allocated memory on success, NULL on failure.
- */
-#define devm_alloc_percpu(dev, type) \
- ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \
- __alignof__(type)))
-
-void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
- size_t align);
-
struct device_dma_parameters {
/*
* a low level driver may set these to teach IOMMU code about
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index 8c5f57e0d613..a2186893b574 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -96,6 +96,22 @@ devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, va_list ap);
char * __printf(3, 4) __malloc
devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
+/**
+ * devm_alloc_percpu - Resource-managed alloc_percpu
+ * @dev: Device to allocate per-cpu memory for
+ * @type: Type to allocate per-cpu memory for
+ *
+ * Managed alloc_percpu. Per-cpu memory allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * RETURNS:
+ * Pointer to allocated memory on success, NULL on failure.
+ */
+#define devm_alloc_percpu(dev, type) \
+ ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), __alignof__(type)))
+
+void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align);
+
unsigned long devm_get_free_pages(struct device *dev, gfp_t gfp_mask, unsigned int order);
void devm_free_pages(struct device *dev, unsigned long addr);
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] devres: Remove unused devm_free_percpu()
2025-11-11 14:39 ` [PATCH v1 1/2] devres: Remove unused devm_free_percpu() Andy Shevchenko
@ 2025-11-11 14:58 ` Philipp Stanner
0 siblings, 0 replies; 6+ messages in thread
From: Philipp Stanner @ 2025-11-11 14:58 UTC (permalink / raw)
To: Andy Shevchenko, Philipp Stanner, Greg Kroah-Hartman, linux-doc,
linux-kernel
Cc: Jonathan Corbet, Rafael J. Wysocki, Danilo Krummrich
On Tue, 2025-11-11 at 15:39 +0100, Andy Shevchenko wrote:
> Remove unused devm_free_percpu().
>
> By the way, it was never used in the drivers/ from day 1.
I mean, most dishes on a restaurant's menu are also never actually
ordered!
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> .../driver-api/driver-model/devres.rst | 1 -
> drivers/base/devres.c | 25 -------------------
> include/linux/device.h | 1 -
I think you forgot Documentation/
devm_free_percpu() is mentioned there.
P.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h
2025-11-11 14:39 ` [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h Andy Shevchenko
@ 2025-11-11 16:33 ` kernel test robot
2025-11-13 4:49 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2025-11-11 16:33 UTC (permalink / raw)
To: Andy Shevchenko, Philipp Stanner, Greg Kroah-Hartman, linux-doc,
linux-kernel
Cc: llvm, oe-kbuild-all, Jonathan Corbet, Rafael J. Wysocki,
Danilo Krummrich
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.18-rc5 next-20251111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/devres-Remove-unused-devm_free_percpu/20251111-230827
base: driver-core/driver-core-testing
patch link: https://lore.kernel.org/r/20251111144104.910241-3-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h
config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20251112/202511120059.G3PR823H-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 996639d6ebb86ff15a8c99b67f1c2e2117636ae7)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251112/202511120059.G3PR823H-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511120059.G3PR823H-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/gpio/gpiolib-devres.c:9:
>> include/linux/device/devres.h:113:6: error: variable has incomplete type 'void'
113 | void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align);
| ^
include/linux/compiler_types.h:60:19: note: expanded from macro '__percpu'
60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
| ^
In file included from drivers/gpio/gpiolib-devres.c:9:
>> include/linux/device/devres.h:113:15: error: expected ';' after top level declarator
113 | void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align);
| ^
In file included from drivers/gpio/gpiolib-devres.c:17:
In file included from drivers/gpio/gpiolib.h:12:
In file included from include/linux/cdev.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:20:
In file included from include/linux/elf.h:6:
In file included from arch/loongarch/include/asm/elf.h:9:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/gpio/gpiolib-devres.c:17:
In file included from drivers/gpio/gpiolib.h:12:
In file included from include/linux/cdev.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:20:
In file included from include/linux/elf.h:6:
In file included from arch/loongarch/include/asm/elf.h:9:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/gpio/gpiolib-devres.c:17:
In file included from drivers/gpio/gpiolib.h:12:
In file included from include/linux/cdev.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:20:
In file included from include/linux/elf.h:6:
In file included from arch/loongarch/include/asm/elf.h:9:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
99 | set->sig[1] | set->sig[0]) == 0;
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/gpio/gpiolib-devres.c:17:
In file included from drivers/gpio/gpiolib.h:12:
In file included from include/linux/cdev.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:20:
In file included from include/linux/elf.h:6:
In file included from arch/loongarch/include/asm/elf.h:9:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
101 | return (set->sig[1] | set->sig[0]) == 0;
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/gpio/gpiolib-devres.c:17:
In file included from drivers/gpio/gpiolib.h:12:
In file included from include/linux/cdev.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:20:
In file included from include/linux/elf.h:6:
In file included from arch/loongarch/include/asm/elf.h:9:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/gpio/gpiolib-devres.c:17:
In file included from drivers/gpio/gpiolib.h:12:
In file included from include/linux/cdev.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:20:
In file included from include/linux/elf.h:6:
In file included from arch/loongarch/include/asm/elf.h:9:
vim +/void +113 include/linux/device/devres.h
98
99 /**
100 * devm_alloc_percpu - Resource-managed alloc_percpu
101 * @dev: Device to allocate per-cpu memory for
102 * @type: Type to allocate per-cpu memory for
103 *
104 * Managed alloc_percpu. Per-cpu memory allocated with this function is
105 * automatically freed on driver detach.
106 *
107 * RETURNS:
108 * Pointer to allocated memory on success, NULL on failure.
109 */
110 #define devm_alloc_percpu(dev, type) \
111 ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), __alignof__(type)))
112
> 113 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align);
114
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h
2025-11-11 14:39 ` [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h Andy Shevchenko
2025-11-11 16:33 ` kernel test robot
@ 2025-11-13 4:49 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2025-11-13 4:49 UTC (permalink / raw)
To: Andy Shevchenko, Philipp Stanner, Greg Kroah-Hartman, linux-doc,
linux-kernel
Cc: llvm, oe-kbuild-all, Jonathan Corbet, Rafael J. Wysocki,
Danilo Krummrich
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.18-rc5 next-20251112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/devres-Remove-unused-devm_free_percpu/20251111-230827
base: driver-core/driver-core-testing
patch link: https://lore.kernel.org/r/20251111144104.910241-3-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h
config: i386-buildonly-randconfig-004-20251112 (https://download.01.org/0day-ci/archive/20251112/202511122250.550UBJAu-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251112/202511122250.550UBJAu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511122250.550UBJAu-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/gpio/gpiolib-devres.c:9:
>> include/linux/device/devres.h:113:6: error: variable has incomplete type 'void __attribute__((btf_type_tag("percpu")))' (aka 'void')
113 | void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align);
| ^
include/linux/compiler_types.h:60:19: note: expanded from macro '__percpu'
60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
| ^
In file included from drivers/gpio/gpiolib-devres.c:9:
include/linux/device/devres.h:113:14: error: expected ';' after top level declarator
113 | void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align);
| ^
| ;
2 errors generated.
vim +113 include/linux/device/devres.h
98
99 /**
100 * devm_alloc_percpu - Resource-managed alloc_percpu
101 * @dev: Device to allocate per-cpu memory for
102 * @type: Type to allocate per-cpu memory for
103 *
104 * Managed alloc_percpu. Per-cpu memory allocated with this function is
105 * automatically freed on driver detach.
106 *
107 * RETURNS:
108 * Pointer to allocated memory on success, NULL on failure.
109 */
110 #define devm_alloc_percpu(dev, type) \
111 ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), __alignof__(type)))
112
> 113 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, size_t align);
114
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-13 4:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 14:39 [PATCH v1 0/2] devres: clean up and move percpu allocator Andy Shevchenko
2025-11-11 14:39 ` [PATCH v1 1/2] devres: Remove unused devm_free_percpu() Andy Shevchenko
2025-11-11 14:58 ` Philipp Stanner
2025-11-11 14:39 ` [PATCH v1 2/2] devres: Move devm_alloc_percpu() and related to devres.h Andy Shevchenko
2025-11-11 16:33 ` kernel test robot
2025-11-13 4:49 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).