From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2711C43331 for ; Thu, 7 Nov 2019 18:07:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8213920869 for ; Thu, 7 Nov 2019 18:07:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="H3Ys3Y9i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8213920869 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 30DD26B0005; Thu, 7 Nov 2019 13:07:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BE8B6B0007; Thu, 7 Nov 2019 13:07:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FBBD6B0008; Thu, 7 Nov 2019 13:07:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 034E76B0005 for ; Thu, 7 Nov 2019 13:07:55 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 9AD7B52DD for ; Thu, 7 Nov 2019 18:07:55 +0000 (UTC) X-FDA: 76130264910.19.bag41_ae9cd2f2fa2f X-HE-Tag: bag41_ae9cd2f2fa2f X-Filterd-Recvd-Size: 5651 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Nov 2019 18:07:54 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id az9so1192432plb.11 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=jDzOZM6IR49ABMo56923ixXf+FeQTfbnaBx0Ui7whOGkK1VFGdicDY4j4rX4I3Ifxs o+KuAcF/MAFzZeKHD4drIkjqAojdC+cWZl5u8u1wv67uT4Knc3eTyX7RupaWzXk2ez/W dNwqkEZiGfIYKt6gzz8W3501yda0Nf3tICMaUdOn5Zciyu6wYjzNEaTufZImcxd8GZWR OZ8x4bVnngXfrUGU081PK7k/bdJroU65aqjubEe4o59f75AVGf/UNGv0NeCYv1XOJFKw 4oQ5r1WxXcDbOdiBr84tn/WvQKXmuaaeryYAmmJqcsmFndryhLnv422lKLaG2NxeY7uK //rw== X-Gm-Message-State: APjAAAWsdmavSVsMnwSUd6uOyINOMzh89+dQE4/stsubeI3FO/MvCkmV eAltZmQOZ7ny94sfwQB3zA6z3Q== X-Google-Smtp-Source: APXvYqwl5+VGy63KgJVXB72ntOstsTKhQwWdAblR1MU+HZBKAOz0xs7UVTy3IO4zfFPaOVDD44GKtA== 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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