Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1309968ybx; Thu, 7 Nov 2019 10:11:09 -0800 (PST) X-Google-Smtp-Source: APXvYqzKWSx23KQd+N8ACEYJN3PCojxU8hQyUcIwoE5lFPrsmuxe5NtaICPxGYJMs56HSGS/3vex X-Received: by 2002:a17:906:3418:: with SMTP id c24mr4440328ejb.121.1573150268857; Thu, 07 Nov 2019 10:11:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573150268; cv=none; d=google.com; s=arc-20160816; b=i7duhl5U5DVy0ejSxWcRPDnzI8eC2F4Qu4ZCVCE5vFHgrDHzVjbSi/lIHBYEXq4zzj TprZaI2FzymjdhrbirKkIJxX+NPJTR5mCPnwLkIvryn8guhKx8L8dECyCKdF7o6fV53A CtyYsS4Wb2A+XlhFGYGoExshrcBfbRzDW4uNzuamZu8vT6yIvE6mb5hn5H0V+sQ+7b9T MXE3HWzBeccoDDdMfXR6ThFsQtuWPu64xVDCfoOJahlm3lM0xRQASyzGqq1BxcFOylSs pkFBrgtRYioPO6OrlUth/8FM9R4SDkVPKTURNn7Ce11KMzcxzeuZPiRTOOxOQrxLc1dx CxsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uOLEs/Ylzowrvsp32OIANhzhopJpqXzqpob5e3gHNYE=; b=Pj4OKvCzciYYgppQ1mnUCqlcgLRkGU5c6UQKS/mRFylBGKyMsLyHi9IsbD9Xt57Tu9 0r7b3Bwqd7960Xcw0EsMb89QKVk3ihdrGQl3rdq6DMsTgLRc8RJPESjOzYDKvUypuVdu sUzaocfbZapLms5c486Gkt6YEitUkPUacBBw2c5BmFomYzkx/kQPEkZCXZ8upZreN1yh Ym/PAjzbBTqeS/eXwUCLF23SHl/YecJLlFFV4qaOqA7oG7OZi0dxi30EAPBWcj8C5R8a xD/64d3Ty9K89215RMWeSftTPGB+tHAroch3nAnM0AmUI5Z4iuD5RHXjoE5F8Y9LMjk3 XHJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=H3Ys3Y9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11si1951720ejw.201.2019.11.07.10.10.45; Thu, 07 Nov 2019 10:11:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=H3Ys3Y9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727534AbfKGSHy (ORCPT + 99 others); Thu, 7 Nov 2019 13:07:54 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39185 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbfKGSHy (ORCPT ); Thu, 7 Nov 2019 13:07:54 -0500 Received: by mail-pl1-f195.google.com with SMTP id o9so2035292plk.6 for ; Thu, 07 Nov 2019 10:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uOLEs/Ylzowrvsp32OIANhzhopJpqXzqpob5e3gHNYE=; b=H3Ys3Y9iSkfRE4KsxqlDsTsW3qNKk0mS3MI3wfGz6aXqLvHeUsP3V+2MyZPPJnhqYY x5r39yYrIrLDhMygYIe+zjcDQpNQfKxonbdBQ2vYPGTwQXLh0SHQx86n5ZuVyxjx0B6e EQZUi+Dra8zss3AFzJYiPWDxR1wCG4vsDwNm4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uOLEs/Ylzowrvsp32OIANhzhopJpqXzqpob5e3gHNYE=; b=AbmI8jsR7kArTdIWl4iGJW7XSyzDs0SZXEKG0yF/wXoAyqs7f5X5DmsG72dz7sbQVh xWsefB0GMEIA0StL9yFtqNmBIpMSrrf49QInOj2uWAhSaq00AMo5zDXah1ZhCaDVLe3l ZtVT3Xx5Rvh2DlUKBIhgIwx0NJpvKWHRETLyrSB0l1mgu1lpISYG35PWPepjUT6N1aHc OG6YJwB/O+bfZy34OC7EKhU3tmMBO8f+feHk0K+7/aqlW61uQRYR8b0LzspIf2Ndwr97 HYczKyLWPfJkpMXol4OUr5NqT+ALvePRGfWCi4qB2nd+RND/+ybI1msGeYtHuIk93doo nB2A== X-Gm-Message-State: APjAAAWM2Qd9OG68J35lz5XiYI4AqP7JzEC0hkx61vgLr830Ep2bzWgE 19q7/RNg9qtu6j/I6YnXB75icA== X-Received: by 2002:a17:90a:80cc:: with SMTP id k12mr7125259pjw.58.1573150073574; Thu, 07 Nov 2019 10:07:53 -0800 (PST) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id f24sm2777882pjp.12.2019.11.07.10.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 10:07:52 -0800 (PST) Date: Thu, 7 Nov 2019 13:07:51 -0500 From: Joel Fernandes To: Petr Mladek Cc: linux-kernel@vger.kernel.org, Ioannis Ilkos , 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 , Andy Shevchenko , Changbin Du , Ingo Molnar , Joe Perches , Kees Cook , linux-mm@kvack.org, Michal Hocko , "Rafael J. Wysocki" , Sakari Ailus , Sergey Senozhatsky , Stephen Rothwell , Steven Rostedt Subject: Re: [PATCH] rss_stat: Add support to detect RSS updates of external mm Message-ID: <20191107180751.GA3846@google.com> References: <20191106024452.81923-1-joel@joelfernandes.org> <20191106085959.ae2dgvmny3njnk7n@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191106085959.ae2dgvmny3njnk7n@pathway.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(¬_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