public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uprobes: Use better bitmap_zalloc()
@ 2021-05-29 11:15 Kefeng Wang
  2021-05-29 13:23 ` kernel test robot
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Kefeng Wang @ 2021-05-29 11:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Kefeng Wang, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland

Use better bitmap_zalloc() to allocate bitmap.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 kernel/events/uprobes.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 907d4ee00cb2..8160d2e53219 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1487,8 +1487,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 	if (unlikely(!area))
 		goto out;
 
-	area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long),
-			       GFP_KERNEL);
+	area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
 	if (!area->bitmap)
 		goto free_area;
 
@@ -1512,7 +1511,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 
 	__free_page(area->pages[0]);
  free_bitmap:
-	kfree(area->bitmap);
+	bitmap_kfree(area->bitmap);
  free_area:
 	kfree(area);
  out:
@@ -1553,7 +1552,7 @@ void uprobe_clear_state(struct mm_struct *mm)
 		return;
 
 	put_page(area->pages[0]);
-	kfree(area->bitmap);
+	bitmap_kfree(area->bitmap);
 	kfree(area);
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] uprobes: Use better bitmap_zalloc()
  2021-05-29 11:15 [PATCH] uprobes: Use better bitmap_zalloc() Kefeng Wang
@ 2021-05-29 13:23 ` kernel test robot
  2021-05-29 14:31 ` kernel test robot
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-05-29 13:23 UTC (permalink / raw)
  To: Kefeng Wang, linux-kernel
  Cc: kbuild-all, clang-built-linux, Kefeng Wang, Peter Zijlstra,
	Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland

[-- Attachment #1: Type: text/plain, Size: 4451 bytes --]

Hi Kefeng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tip/perf/core]
[also build test WARNING on linux/master linus/master v5.13-rc3 next-20210528]
[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]

url:    https://github.com/0day-ci/linux/commits/Kefeng-Wang/uprobes-Use-better-bitmap_zalloc/20210529-190812
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 875dd7bf548104bc1d2c5784a6af6cf38215a216
config: x86_64-randconfig-a006-20210529 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project bc6799f2f79f0ae87e9f1ebf9d25ba799fbd25a9)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/346b85395aa484f7b3b64a53e197bc7f56a4e719
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Kefeng-Wang/uprobes-Use-better-bitmap_zalloc/20210529-190812
        git checkout 346b85395aa484f7b3b64a53e197bc7f56a4e719
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   kernel/events/uprobes.c:1490:17: error: implicit declaration of function 'bitmap_kzalloc' [-Werror,-Wimplicit-function-declaration]
           area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
                          ^
   kernel/events/uprobes.c:1490:17: note: did you mean 'bitmap_zalloc'?
   include/linux/bitmap.h:125:16: note: 'bitmap_zalloc' declared here
   unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
                  ^
>> kernel/events/uprobes.c:1490:15: warning: incompatible integer to pointer conversion assigning to 'unsigned long *' from 'int' [-Wint-conversion]
           area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/events/uprobes.c:1514:2: error: implicit declaration of function 'bitmap_kfree' [-Werror,-Wimplicit-function-declaration]
           bitmap_kfree(area->bitmap);
           ^
   kernel/events/uprobes.c:1514:2: note: did you mean 'bitmap_free'?
   include/linux/bitmap.h:126:6: note: 'bitmap_free' declared here
   void bitmap_free(const unsigned long *bitmap);
        ^
   kernel/events/uprobes.c:1555:2: error: implicit declaration of function 'bitmap_kfree' [-Werror,-Wimplicit-function-declaration]
           bitmap_kfree(area->bitmap);
           ^
   1 warning and 3 errors generated.


vim +1490 kernel/events/uprobes.c

  1479	
  1480	static struct xol_area *__create_xol_area(unsigned long vaddr)
  1481	{
  1482		struct mm_struct *mm = current->mm;
  1483		uprobe_opcode_t insn = UPROBE_SWBP_INSN;
  1484		struct xol_area *area;
  1485	
  1486		area = kmalloc(sizeof(*area), GFP_KERNEL);
  1487		if (unlikely(!area))
  1488			goto out;
  1489	
> 1490		area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
  1491		if (!area->bitmap)
  1492			goto free_area;
  1493	
  1494		area->xol_mapping.name = "[uprobes]";
  1495		area->xol_mapping.fault = NULL;
  1496		area->xol_mapping.pages = area->pages;
  1497		area->pages[0] = alloc_page(GFP_HIGHUSER);
  1498		if (!area->pages[0])
  1499			goto free_bitmap;
  1500		area->pages[1] = NULL;
  1501	
  1502		area->vaddr = vaddr;
  1503		init_waitqueue_head(&area->wq);
  1504		/* Reserve the 1st slot for get_trampoline_vaddr() */
  1505		set_bit(0, area->bitmap);
  1506		atomic_set(&area->slot_count, 1);
  1507		arch_uprobe_copy_ixol(area->pages[0], 0, &insn, UPROBE_SWBP_INSN_SIZE);
  1508	
  1509		if (!xol_add_vma(mm, area))
  1510			return area;
  1511	
  1512		__free_page(area->pages[0]);
  1513	 free_bitmap:
  1514		bitmap_kfree(area->bitmap);
  1515	 free_area:
  1516		kfree(area);
  1517	 out:
  1518		return NULL;
  1519	}
  1520	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35444 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] uprobes: Use better bitmap_zalloc()
  2021-05-29 11:15 [PATCH] uprobes: Use better bitmap_zalloc() Kefeng Wang
  2021-05-29 13:23 ` kernel test robot
@ 2021-05-29 14:31 ` kernel test robot
  2021-05-29 15:56 ` kernel test robot
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-05-29 14:31 UTC (permalink / raw)
  To: Kefeng Wang, linux-kernel
  Cc: kbuild-all, Kefeng Wang, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland

[-- Attachment #1: Type: text/plain, Size: 3634 bytes --]

Hi Kefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/perf/core]
[also build test ERROR on linux/master linus/master v5.13-rc3 next-20210528]
[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]

url:    https://github.com/0day-ci/linux/commits/Kefeng-Wang/uprobes-Use-better-bitmap_zalloc/20210529-190812
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 875dd7bf548104bc1d2c5784a6af6cf38215a216
config: x86_64-rhel-8.3-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/346b85395aa484f7b3b64a53e197bc7f56a4e719
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Kefeng-Wang/uprobes-Use-better-bitmap_zalloc/20210529-190812
        git checkout 346b85395aa484f7b3b64a53e197bc7f56a4e719
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   kernel/events/uprobes.c: In function '__create_xol_area':
>> kernel/events/uprobes.c:1490:17: error: implicit declaration of function 'bitmap_kzalloc'; did you mean 'bitmap_zalloc'? [-Werror=implicit-function-declaration]
    1490 |  area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
         |                 ^~~~~~~~~~~~~~
         |                 bitmap_zalloc
   kernel/events/uprobes.c:1490:15: warning: assignment to 'long unsigned int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    1490 |  area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
         |               ^
>> kernel/events/uprobes.c:1514:2: error: implicit declaration of function 'bitmap_kfree'; did you mean 'bitmap_free'? [-Werror=implicit-function-declaration]
    1514 |  bitmap_kfree(area->bitmap);
         |  ^~~~~~~~~~~~
         |  bitmap_free
   cc1: some warnings being treated as errors


vim +1490 kernel/events/uprobes.c

  1479	
  1480	static struct xol_area *__create_xol_area(unsigned long vaddr)
  1481	{
  1482		struct mm_struct *mm = current->mm;
  1483		uprobe_opcode_t insn = UPROBE_SWBP_INSN;
  1484		struct xol_area *area;
  1485	
  1486		area = kmalloc(sizeof(*area), GFP_KERNEL);
  1487		if (unlikely(!area))
  1488			goto out;
  1489	
> 1490		area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
  1491		if (!area->bitmap)
  1492			goto free_area;
  1493	
  1494		area->xol_mapping.name = "[uprobes]";
  1495		area->xol_mapping.fault = NULL;
  1496		area->xol_mapping.pages = area->pages;
  1497		area->pages[0] = alloc_page(GFP_HIGHUSER);
  1498		if (!area->pages[0])
  1499			goto free_bitmap;
  1500		area->pages[1] = NULL;
  1501	
  1502		area->vaddr = vaddr;
  1503		init_waitqueue_head(&area->wq);
  1504		/* Reserve the 1st slot for get_trampoline_vaddr() */
  1505		set_bit(0, area->bitmap);
  1506		atomic_set(&area->slot_count, 1);
  1507		arch_uprobe_copy_ixol(area->pages[0], 0, &insn, UPROBE_SWBP_INSN_SIZE);
  1508	
  1509		if (!xol_add_vma(mm, area))
  1510			return area;
  1511	
  1512		__free_page(area->pages[0]);
  1513	 free_bitmap:
> 1514		bitmap_kfree(area->bitmap);
  1515	 free_area:
  1516		kfree(area);
  1517	 out:
  1518		return NULL;
  1519	}
  1520	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41780 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] uprobes: Use better bitmap_zalloc()
  2021-05-29 11:15 [PATCH] uprobes: Use better bitmap_zalloc() Kefeng Wang
  2021-05-29 13:23 ` kernel test robot
  2021-05-29 14:31 ` kernel test robot
@ 2021-05-29 15:56 ` kernel test robot
  2021-05-31  0:54 ` Kefeng Wang
  2021-05-31  1:38 ` [PATCH v2] uprobes: Use better bitmap_zalloc/free Kefeng Wang
  4 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-05-29 15:56 UTC (permalink / raw)
  To: Kefeng Wang, linux-kernel
  Cc: kbuild-all, clang-built-linux, Kefeng Wang, Peter Zijlstra,
	Ingo Molnar, Arnaldo Carvalho de Melo, Mark Rutland

[-- Attachment #1: Type: text/plain, Size: 4458 bytes --]

Hi Kefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/perf/core]
[also build test ERROR on linux/master linus/master v5.13-rc3 next-20210528]
[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]

url:    https://github.com/0day-ci/linux/commits/Kefeng-Wang/uprobes-Use-better-bitmap_zalloc/20210529-190812
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 875dd7bf548104bc1d2c5784a6af6cf38215a216
config: x86_64-randconfig-a006-20210529 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project bc6799f2f79f0ae87e9f1ebf9d25ba799fbd25a9)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/346b85395aa484f7b3b64a53e197bc7f56a4e719
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Kefeng-Wang/uprobes-Use-better-bitmap_zalloc/20210529-190812
        git checkout 346b85395aa484f7b3b64a53e197bc7f56a4e719
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> kernel/events/uprobes.c:1490:17: error: implicit declaration of function 'bitmap_kzalloc' [-Werror,-Wimplicit-function-declaration]
           area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
                          ^
   kernel/events/uprobes.c:1490:17: note: did you mean 'bitmap_zalloc'?
   include/linux/bitmap.h:125:16: note: 'bitmap_zalloc' declared here
   unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
                  ^
   kernel/events/uprobes.c:1490:15: warning: incompatible integer to pointer conversion assigning to 'unsigned long *' from 'int' [-Wint-conversion]
           area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/events/uprobes.c:1514:2: error: implicit declaration of function 'bitmap_kfree' [-Werror,-Wimplicit-function-declaration]
           bitmap_kfree(area->bitmap);
           ^
   kernel/events/uprobes.c:1514:2: note: did you mean 'bitmap_free'?
   include/linux/bitmap.h:126:6: note: 'bitmap_free' declared here
   void bitmap_free(const unsigned long *bitmap);
        ^
   kernel/events/uprobes.c:1555:2: error: implicit declaration of function 'bitmap_kfree' [-Werror,-Wimplicit-function-declaration]
           bitmap_kfree(area->bitmap);
           ^
   1 warning and 3 errors generated.


vim +/bitmap_kzalloc +1490 kernel/events/uprobes.c

  1479	
  1480	static struct xol_area *__create_xol_area(unsigned long vaddr)
  1481	{
  1482		struct mm_struct *mm = current->mm;
  1483		uprobe_opcode_t insn = UPROBE_SWBP_INSN;
  1484		struct xol_area *area;
  1485	
  1486		area = kmalloc(sizeof(*area), GFP_KERNEL);
  1487		if (unlikely(!area))
  1488			goto out;
  1489	
> 1490		area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
  1491		if (!area->bitmap)
  1492			goto free_area;
  1493	
  1494		area->xol_mapping.name = "[uprobes]";
  1495		area->xol_mapping.fault = NULL;
  1496		area->xol_mapping.pages = area->pages;
  1497		area->pages[0] = alloc_page(GFP_HIGHUSER);
  1498		if (!area->pages[0])
  1499			goto free_bitmap;
  1500		area->pages[1] = NULL;
  1501	
  1502		area->vaddr = vaddr;
  1503		init_waitqueue_head(&area->wq);
  1504		/* Reserve the 1st slot for get_trampoline_vaddr() */
  1505		set_bit(0, area->bitmap);
  1506		atomic_set(&area->slot_count, 1);
  1507		arch_uprobe_copy_ixol(area->pages[0], 0, &insn, UPROBE_SWBP_INSN_SIZE);
  1508	
  1509		if (!xol_add_vma(mm, area))
  1510			return area;
  1511	
  1512		__free_page(area->pages[0]);
  1513	 free_bitmap:
> 1514		bitmap_kfree(area->bitmap);
  1515	 free_area:
  1516		kfree(area);
  1517	 out:
  1518		return NULL;
  1519	}
  1520	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35444 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] uprobes: Use better bitmap_zalloc()
  2021-05-29 11:15 [PATCH] uprobes: Use better bitmap_zalloc() Kefeng Wang
                   ` (2 preceding siblings ...)
  2021-05-29 15:56 ` kernel test robot
@ 2021-05-31  0:54 ` Kefeng Wang
  2021-05-31  1:38 ` [PATCH v2] uprobes: Use better bitmap_zalloc/free Kefeng Wang
  4 siblings, 0 replies; 6+ messages in thread
From: Kefeng Wang @ 2021-05-31  0:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland

sorry for the mistake,  will fix.

On 2021/5/29 19:15, Kefeng Wang wrote:
> Use better bitmap_zalloc() to allocate bitmap.
>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   kernel/events/uprobes.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 907d4ee00cb2..8160d2e53219 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1487,8 +1487,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
>   	if (unlikely(!area))
>   		goto out;
>   
> -	area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long),
> -			       GFP_KERNEL);
> +	area->bitmap = bitmap_kzalloc(UINSNS_PER_PAGE, GFP_KERNEL);
>   	if (!area->bitmap)
>   		goto free_area;
>   
> @@ -1512,7 +1511,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
>   
>   	__free_page(area->pages[0]);
>    free_bitmap:
> -	kfree(area->bitmap);
> +	bitmap_kfree(area->bitmap);
>    free_area:
>   	kfree(area);
>    out:
> @@ -1553,7 +1552,7 @@ void uprobe_clear_state(struct mm_struct *mm)
>   		return;
>   
>   	put_page(area->pages[0]);
> -	kfree(area->bitmap);
> +	bitmap_kfree(area->bitmap);
>   	kfree(area);
>   }
>   

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] uprobes: Use better bitmap_zalloc/free
  2021-05-29 11:15 [PATCH] uprobes: Use better bitmap_zalloc() Kefeng Wang
                   ` (3 preceding siblings ...)
  2021-05-31  0:54 ` Kefeng Wang
@ 2021-05-31  1:38 ` Kefeng Wang
  4 siblings, 0 replies; 6+ messages in thread
From: Kefeng Wang @ 2021-05-31  1:38 UTC (permalink / raw)
  To: linux-kernel
  Cc: Kefeng Wang, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland

Use better bitmap_zalloc/free() to allocate and free bitmap.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
v2: fix the copy err, should found it when enable UPROBES
 kernel/events/uprobes.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 907d4ee00cb2..3f1b8e9d9af6 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1487,8 +1487,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 	if (unlikely(!area))
 		goto out;
 
-	area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long),
-			       GFP_KERNEL);
+	area->bitmap = bitmap_zalloc(UINSNS_PER_PAGE, GFP_KERNEL);
 	if (!area->bitmap)
 		goto free_area;
 
@@ -1512,7 +1511,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 
 	__free_page(area->pages[0]);
  free_bitmap:
-	kfree(area->bitmap);
+	bitmap_free(area->bitmap);
  free_area:
 	kfree(area);
  out:
@@ -1553,7 +1552,7 @@ void uprobe_clear_state(struct mm_struct *mm)
 		return;
 
 	put_page(area->pages[0]);
-	kfree(area->bitmap);
+	bitmap_free(area->bitmap);
 	kfree(area);
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-31  1:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-29 11:15 [PATCH] uprobes: Use better bitmap_zalloc() Kefeng Wang
2021-05-29 13:23 ` kernel test robot
2021-05-29 14:31 ` kernel test robot
2021-05-29 15:56 ` kernel test robot
2021-05-31  0:54 ` Kefeng Wang
2021-05-31  1:38 ` [PATCH v2] uprobes: Use better bitmap_zalloc/free Kefeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox