linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joel Fernandes <joel@joelfernandes.org>
To: Petr Mladek <pmladek@suse.com>
Cc: linux-kernel@vger.kernel.org, Ioannis Ilkos <ilkos@google.com>,
	minchan@google.com, primiano@google.com, fmayer@google.com,
	hjd@google.com, joaodias@google.com, lalitm@google.com,
	rslawik@google.com, sspatil@google.com, timmurray@google.com,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Changbin Du <changbin.du@intel.com>,
	Ingo Molnar <mingo@redhat.com>, Joe Perches <joe@perches.com>,
	Kees Cook <keescook@chromium.org>,
	linux-mm@kvack.org, Michal Hocko <mhocko@suse.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] rss_stat: Add support to detect RSS updates of external mm
Date: Thu, 7 Nov 2019 13:07:51 -0500	[thread overview]
Message-ID: <20191107180751.GA3846@google.com> (raw)
In-Reply-To: <20191106085959.ae2dgvmny3njnk7n@pathway.suse.cz>

On Wed, Nov 06, 2019 at 09:59:59AM +0100, Petr Mladek wrote:
> On Tue 2019-11-05 21:44:51, Joel Fernandes (Google) wrote:
> > Also vsprintf.c is refactored a bit to allow reuse of hashing code.
> 
> I agree with Sergey that it would make sense to move this outside
> vsprintf.c.

I am of the opinion that its Ok to have it this way and I am not sure if
another translation unit is worth it just for this. If we have more users,
then yes we can consider splitting into its own translation unit at that
time.

If Andrew Morton objects, then I'll do it since the intention was for this
patch to go through his tree and I believe he is Ok with it this way.

> > diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> > index dee8fc467fcf..401baaac1813 100644
> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -761,11 +761,34 @@ static int __init initialize_ptr_random(void)
> >  early_initcall(initialize_ptr_random);
> >  
> >  /* Maps a pointer to a 32 bit unique identifier. */
> > +int ptr_to_hashval(const void *ptr, unsigned long *hashval_out)
> > +{
> > +	const char *str = sizeof(ptr) == 8 ? "(____ptrval____)" : "(ptrval)";
> 
> str is unused.

I believe Andrew has already fixed this in his tree.

linux-next has local variable removed now:
7422993b4f8e ("rss_stat-add-support-to-detect-rss-updates-of-external-mm-fix")

> > +	unsigned long hashval;
> 
> IMHO, this local variable unnecessarily complicates the code.
> I would use the pointer directly and let compiler to optimize.

Agreed.

thanks,

 - Joel


> > +	if (static_branch_unlikely(&not_filled_random_ptr_key))
> > +		return -EAGAIN;
> > +
> > +#ifdef CONFIG_64BIT
> > +	hashval = (unsigned long)siphash_1u64((u64)ptr, &ptr_key);
> > +	/*
> > +	 * Mask off the first 32 bits, this makes explicit that we have
> > +	 * modified the address (and 32 bits is plenty for a unique ID).
> > +	 */
> > +	hashval = hashval & 0xffffffff;
> > +#else
> > +	hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key);
> > +#endif
> > +	*hashval_out = hashval;
> > +	return 0;
> > +}
> 
> Best Regards,
> Petr


  reply	other threads:[~2019-11-07 18:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06  2:44 Joel Fernandes (Google)
2019-11-06  8:00 ` Sergey Senozhatsky
2019-11-06  8:59 ` Petr Mladek
2019-11-07 18:07   ` Joel Fernandes [this message]
2019-11-08  8:47     ` Petr Mladek
2019-11-13 20:38 ` Steven Rostedt
2019-11-14 16:46   ` Joel Fernandes
2019-11-14 17:20     ` Steven Rostedt

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=20191107180751.GA3846@google.com \
    --to=joel@joelfernandes.org \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=changbin.du@intel.com \
    --cc=fmayer@google.com \
    --cc=hjd@google.com \
    --cc=ilkos@google.com \
    --cc=joaodias@google.com \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=lalitm@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=minchan@google.com \
    --cc=mingo@redhat.com \
    --cc=pmladek@suse.com \
    --cc=primiano@google.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=rslawik@google.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=sfr@canb.auug.org.au \
    --cc=sspatil@google.com \
    --cc=timmurray@google.com \
    /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