linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: "Pulavarty, Badari" <badari.pulavarty@intel.com>
Cc: "damon@lists.linux.dev" <damon@lists.linux.dev>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH] DAMON dbgfs_mk_context() error handling
Date: Sun, 14 Aug 2022 16:32:34 +0000	[thread overview]
Message-ID: <20220814163234.52190-1-sj@kernel.org> (raw)
In-Reply-To: <DM6PR11MB3978994F75A4104D714437379C679@DM6PR11MB3978.namprd11.prod.outlook.com>

Hi Badari,

On Fri, 12 Aug 2022 18:01:25 +0000 "Pulavarty, Badari" <badari.pulavarty@intel.com> wrote:

> damon dbgfs_mk_context() does not handle error from debugfs_create_dir() correctly.

Let's wrpa the body lines at 75 columns[1].

> 
> For example, if one tries to create a context with existing name, debugfs_create_dir() fails
> with -EEXIST, but dbgfs_mk_context() assumes the call is successful and adds another entry - which
> will cause failures when try to enable the monitor.
> 
> Test case:
> 
> echo "off" >  /sys/kernel/debug/damon/monitor_on
> echo "abc" > /sys/kernel/debug/damon/mk_context
> echo "abc" > /sys/kernel/debug/damon/mk_context
> echo <pid> > /sys/kernel/debug/damon/target_ids
> echo "on" > /sys/kernel/debug/damon/monitor_on  <<< fails to enable monitor
> 
> Signed-off-by: Badari Pulavarty badari.pulavarty@intel.com
> ---
> --- orig/mm/damon/dbgfs.c       2022-08-05 13:35:54.416831666 -0400
> +++ new/mm/damon/dbgfs.c        2022-08-05 13:44:25.121849930 -0400
> @@ -721,6 +721,9 @@ static int dbgfs_mk_context(char *name)
>                 return -ENOENT;
> 
>         new_dir = debugfs_create_dir(name, root);
> +       if (IS_ERR(new_dir)) {
> +               return PTR_ERR(new_dir);
> +       }

Nice finding, thank you!  But, the return value of the debugfs call is
intentionally ignored[2].  How about doing the duplicated name check in
dbgfs_mk_context() itself before the debugfs_create_dir() call?

[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format
[2] https://lore.kernel.org/linux-mm/20210205155902.31102-1-sjpark@amazon.com/


Thanks,
SJ

>         dbgfs_dirs[dbgfs_nr_ctxs] = new_dir;
> 
>         new_ctx = dbgfs_new_ctx();


  reply	other threads:[~2022-08-14 16:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 18:01 Pulavarty, Badari
2022-08-14 16:32 ` SeongJae Park [this message]
2022-08-15 21:51   ` Pulavarty, Badari
2022-08-15 23:42     ` SeongJae Park
2022-08-15 23:54       ` Pulavarty, Badari
2022-08-16  0:12       ` SeongJae Park
  -- strict thread matches above, loose matches on Subject: below --
2022-08-12 17:57 Pulavarty, Badari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220814163234.52190-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=badari.pulavarty@intel.com \
    --cc=damon@lists.linux.dev \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox