Skip to contentSkip to conversation

mm/damon/sysfs: fix pid leak under fvaddr ops use case

PATCH In review SeongJae Park 3 participants 4 messages May 3, 2022 – May 6, 2022

Subsystems (2)
lore
Share & tools
lore

SeongJae Park

author maintainer
#0 lore raw

PATCH 1/1 mm/damon/sysfs: fix pid leak under fvaddr ops use case

Commit c83136469313 ("mm/damon/sysfs: support fixed virtual address ranges monitoring") in 'mm-unstable' does not put the monitoring target pid when fvaddr ops is used. This commit fixes it to put pid properly.

Andrew, please merge this into the 'mm-unstable' commit ("mm/damon/sysfs: support fixed virtual address ranges monitoring").

Fixes c83136469313 ("mm/damon/sysfs: support fixed virtual address ranges monitoring")
---
 mm/damon/sysfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/damon/sysfs.c +3 -2
index 767ab8c33e4d..f753bb405101 100644
@@ -2086,7 +2086,8 @@ static void damon_sysfs_destroy_targets(struct damon_ctx *ctx)
 	struct damon_target *t, *next;
 
 	damon_for_each_target_safe(t, next, ctx) {
-		if (ctx->ops.id == DAMON_OPS_VADDR)
+		if (ctx->ops.id == DAMON_OPS_VADDR ||
+				ctx->ops.id == DAMON_OPS_FVADDR)
 			put_pid(t->pid);
 		damon_destroy_target(t);
 	}
@@ -2204,7 +2205,7 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx)
 {
 	struct damon_target *t, *next;
 
-	if (ctx->ops.id != DAMON_OPS_VADDR)
+	if (ctx->ops.id != DAMON_OPS_VADDR && ctx->ops.id != DAMON_OPS_FVADDR)
 		return;
 
 	mutex_lock(&ctx->kdamond_lock);
Signature · 1 line
2.25.1
#1 lore raw
I love your patch! Yet something to improve:

Hi SeongJae,

I love your patch! Yet something to improve:

[auto build test ERROR on hnaz-mm/master]

url:    https://github.com/intel-lab-lkp/linux/commits/SeongJae-Park/mm-damon-sysfs-fix-pid-leak-under-fvaddr-ops-use-case/20220504-060657
base:   https://github.com/hnaz/linux-mm master
config: hexagon-randconfig-r045-20220501 (https://download.01.org/0day-ci/archive/20220504/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 363b3a645a1e30011cc8da624f13dac5fd915628)

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
# https://github.com/intel-lab-lkp/linux/commit/60cfe4571b04ef4ca2e34793fbad737bb43dc0c6
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review SeongJae-Park/mm-damon-sysfs-fix-pid-leak-under-fvaddr-ops-use-case/20220504-060657 git checkout 60cfe4571b04ef4ca2e34793fbad737bb43dc0c6
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash mm/damon/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> mm/damon/sysfs.c:2089:20: error: use of undeclared identifier 'DAMON_OPS_FVADDR'; did you mean 'DAMON_OPS_VADDR'?
                                   ctx->ops.id == DAMON_OPS_FVADDR)
                                                  ^~~~~~~~~~~~~~~~
                                                  DAMON_OPS_VADDR
   include/linux/damon.h:267:2: note: 'DAMON_OPS_VADDR' declared here
           DAMON_OPS_VADDR,
           ^
   mm/damon/sysfs.c:2206:55: error: use of undeclared identifier 'DAMON_OPS_FVADDR'; did you mean 'DAMON_OPS_VADDR'?
           if (ctx->ops.id != DAMON_OPS_VADDR && ctx->ops.id != DAMON_OPS_FVADDR)
                                                                ^~~~~~~~~~~~~~~~
                                                                DAMON_OPS_VADDR
   include/linux/damon.h:267:2: note: 'DAMON_OPS_VADDR' declared here
           DAMON_OPS_VADDR,
           ^

2 errors generated.

vim +2089 mm/damon/sysfs.c

2082
2083 static void damon_sysfs_destroy_targets(struct damon_ctx *ctx)
2084 {
2085 struct damon_target *t, *next;
2086
2087 damon_for_each_target_safe(t, next, ctx) {
2088 if (ctx->ops.id == DAMON_OPS_VADDR ||

> 2089					ctx->ops.id == DAMON_OPS_FVADDR)

2090 put_pid(t->pid);
2091 damon_destroy_target(t);
2092 }
2093 }
2094

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
author maintainer
#2 lore raw
Quoted 5 lines · On Wed, 4 May 2022 10:53:47 +0800 kernel test robot <[email protected]> wrote:

Hi SeongJae,

I love your patch! Yet something to improve:

[auto build test ERROR on hnaz-mm/master]

This patch is on top of mm-unstable branch of akpm's mm tree. More specifically, this patch depends on a commit[1] on the tree. So, this error shouldn't occur on top of the tree.

If I'm missing something, please let me know.

[0] git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
[1] https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?h=mm-unstable&id=cb52aff4ed86a5992309bc7efc228303a7dc084d

Thanks,
SJ

Quoted 71 lines

url: https://github.com/intel-lab-lkp/linux/commits/SeongJae-Park/mm-dam=
on-sysfs-fix-pid-leak-under-fvaddr-ops-use-case/20220504-060657

base:   https://github.com/hnaz/linux-mm master
config: hexagon-randconfig-r045-20220501 (https://download.01.org/0day-ci/a=

rchive/20220504/202205041011.jv6vuDe4-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 363b3a= 645a1e30011cc8da624f13dac5fd915628)
reproduce (this is a W=3D1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/=
make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/60cfe4571b04ef4ca2e=
34793fbad737bb43dc0c6
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review SeongJae-Park/mm-damon-sysfs-fix-p=
id-leak-under-fvaddr-ops-use-case/20220504-060657
git checkout 60cfe4571b04ef4ca2e34793fbad737bb43dc0c6
# save the config file
mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross W=3D=
1 O=3Dbuild_dir ARCH=3Dhexagon SHELL=3D/bin/bash mm/damon/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

mm/damon/sysfs.c:2089:20: error: use of undeclared identifier 'DAMON_OPS=

_FVADDR'; did you mean 'DAMON_OPS_VADDR'?

                                   ctx->ops.id =3D=3D DAMON_OPS_FVADDR)
                                                  ^~~~~~~~~~~~~~~~
                                                  DAMON_OPS_VADDR
   include/linux/damon.h:267:2: note: 'DAMON_OPS_VADDR' declared here
           DAMON_OPS_VADDR,
           ^
   mm/damon/sysfs.c:2206:55: error: use of undeclared identifier 'DAMON_OPS=
_FVADDR'; did you mean 'DAMON_OPS_VADDR'?
           if (ctx->ops.id !=3D DAMON_OPS_VADDR && ctx->ops.id !=3D DAMON_O=
PS_FVADDR)
                                                                ^~~~~~~~~~~=

~~~~~
DAMON_OPS_V=
ADDR
include/linux/damon.h:267:2: note: 'DAMON_OPS_VADDR' declared here

           DAMON_OPS_VADDR,
           ^

2 errors generated.

vim +2089 mm/damon/sysfs.c

2082
2083 static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) 2084 {
2085 struct damon_target *t, *next;
2086
2087 damon_for_each_target_safe(t, next, ctx) {
2088 if (ctx->ops.id =3D=3D DAMON_OPS_VADDR ||

Quoted 1 line

2089 ctx->ops.id =3D=3D DAMON_OPS_FVADDR=

)
2090 put_pid(t->pid);
2091 damon_destroy_target(t);
2092 }
2093 }
2094

--
0-DAY CI Kernel Test Service
https://01.org/lkp

#3 lore raw
Quoted 11 lines · SeongJae Park
Quoted 5 lines · On Wed, 4 May 2022 10:53:47 +0800 kernel test robot <[email protected]> wrote:

Hi SeongJae,

I love your patch! Yet something to improve:

[auto build test ERROR on hnaz-mm/master]

This patch is on top of mm-unstable branch of akpm's mm tree. More specifically, this patch depends on a commit[1] on the tree. So, this error shouldn't occur on top of the tree.

Hi SJ,

Thanks for your feedback, it's helpful to improve our system.

Best Regards,
Rong Chen

Quoted 85 lines

If I'm missing something, please let me know.

[0] git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
[1] https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?h=mm-unstable&id=cb52aff4ed86a5992309bc7efc228303a7dc084d

Thanks,
SJ

Quoted 67 lines

url: https://github.com/intel-lab-lkp/linux/commits/SeongJae-Park/mm-dam=
on-sysfs-fix-pid-leak-under-fvaddr-ops-use-case/20220504-060657

base:   https://github.com/hnaz/linux-mm master
config: hexagon-randconfig-r045-20220501 (https://download.01.org/0day-ci/a=

rchive/20220504/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 363b3a= 645a1e30011cc8da624f13dac5fd915628)
reproduce (this is a W=3D1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/=
make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/60cfe4571b04ef4ca2e=
34793fbad737bb43dc0c6
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review SeongJae-Park/mm-damon-sysfs-fix-p=
id-leak-under-fvaddr-ops-use-case/20220504-060657
git checkout 60cfe4571b04ef4ca2e34793fbad737bb43dc0c6
# save the config file
mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross W=3D=
1 O=3Dbuild_dir ARCH=3Dhexagon SHELL=3D/bin/bash mm/damon/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

mm/damon/sysfs.c:2089:20: error: use of undeclared identifier 'DAMON_OPS=

_FVADDR'; did you mean 'DAMON_OPS_VADDR'?

                                    ctx->ops.id =3D=3D DAMON_OPS_FVADDR)
                                                   ^~~~~~~~~~~~~~~~
                                                   DAMON_OPS_VADDR
    include/linux/damon.h:267:2: note: 'DAMON_OPS_VADDR' declared here
            DAMON_OPS_VADDR,
            ^
    mm/damon/sysfs.c:2206:55: error: use of undeclared identifier 'DAMON_OPS=
_FVADDR'; did you mean 'DAMON_OPS_VADDR'?
            if (ctx->ops.id !=3D DAMON_OPS_VADDR && ctx->ops.id !=3D DAMON_O=
PS_FVADDR)
                                                                 ^~~~~~~~~~~=

~~~~~
DAMON_OPS_V=
ADDR
include/linux/damon.h:267:2: note: 'DAMON_OPS_VADDR' declared here
DAMON_OPS_VADDR,
^
2 errors generated.

vim +2089 mm/damon/sysfs.c

   2082
   2083  static void damon_sysfs_destroy_targets(struct damon_ctx *ctx)
   2084  {
   2085          struct damon_target *t, *next;
   2086
   2087          damon_for_each_target_safe(t, next, ctx) {
   2088                  if (ctx->ops.id =3D=3D DAMON_OPS_VADDR ||
Quoted 1 line

2089 ctx->ops.id =3D=3D DAMON_OPS_FVADDR=

)

   2090                          put_pid(t->pid);
   2091                  damon_destroy_target(t);
   2092          }
   2093  }
   2094
Quoted 4 lines

--
0-DAY CI Kernel Test Service
https://01.org/lkp

_______________________________________________
kbuild-all mailing list -- [email protected] To unsubscribe send an email to [email protected]