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.2 required=3.0 tests=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 54224C5DF63 for ; Wed, 6 Nov 2019 09:00:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 161092075C for ; Wed, 6 Nov 2019 09:00:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 161092075C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ADB196B0003; Wed, 6 Nov 2019 04:00:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A64D36B0006; Wed, 6 Nov 2019 04:00:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92EAF6B0007; Wed, 6 Nov 2019 04:00:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 7AF176B0003 for ; Wed, 6 Nov 2019 04:00:04 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 0DA63180AD817 for ; Wed, 6 Nov 2019 09:00:04 +0000 (UTC) X-FDA: 76125255528.10.story60_74f463e7d042e X-HE-Tag: story60_74f463e7d042e X-Filterd-Recvd-Size: 3090 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Nov 2019 09:00:03 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B67A1B24B; Wed, 6 Nov 2019 09:00:00 +0000 (UTC) Date: Wed, 6 Nov 2019 09:59:59 +0100 From: Petr Mladek To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Ioannis Ilkos , minchan@google.com, primiano@google.com, fmayer@google.com, hjd@google.com, joaodias@google.com, joelaf@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: <20191106085959.ae2dgvmny3njnk7n@pathway.suse.cz> References:<20191106024452.81923-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To:<20191106024452.81923-1-joel@joelfernandes.org> User-Agent: NeoMutt/20170912 (1.9.0) 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 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. > 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. > + unsigned long hashval; IMHO, this local variable unnecessarily complicates the code. I would use the pointer directly and let compiler to optimize. > + 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