Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp325330ybx; Wed, 6 Nov 2019 01:01:09 -0800 (PST) X-Google-Smtp-Source: APXvYqyTb0mus6XET/KLYMovkBFo4I+yJ4bpUl1qMLGtFKAyLYNNd3K0BQ0CcAtTAK39sAnVpyRt X-Received: by 2002:a50:8969:: with SMTP id f38mr1391549edf.211.1573030868898; Wed, 06 Nov 2019 01:01:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573030868; cv=none; d=google.com; s=arc-20160816; b=Fe3gdGx42hgwdQXUM3A8KWi5pjRWAiI/m9ukiMbLOIsY65trUlki/do2FpV9Ib+k7+ IiMnKAMO/S5WMKMDhmvnA+8HR3rSOX8rJqlehEqgKSJEPNngJNAjan1EqD1NQJV7Y3Tp 6KU5cgw1DaUOUAxk5IS2Yat4NfXK0WGCsL0egEx0viUmxZdcMKO7Q6KTVAOpViPYG+rP LqNL1sf5z7cuxKKeMpiK6068lTItCUxbZqJXYW3ZwSQTFcdl3aCpii6eSN98pkvoD3+9 3lCMYlXFu1GH7eKzCn2gq4VQZYjaaaFcSwg7WxgAnqq4LPlUka3nRe5tzLHW4BEPwCyw e9Kw== 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; bh=7CqPstpeDqxi+h+7gqHmov8dvhItGJo5YgwRrxnUoBA=; b=qCgT+floi0vpOjUpb5LXK4MBrdkE+hGMCovcDvYJh6Ys/xJRHVrvMPvxEgWqxOvwZP o/9OWtQ92+U3zWwBlt2VYrKj7R+jevNexEavQUOobDkBLJI00Wd3vVAo2hzSHvMK6xLA 0Wzv7LcqyBQZ01NJZKP9fOSlQWMiTjMC948Ox1YQBAD44pueW3hJzpQMBk0Sl+Rkt0D5 9iQByFYOnx7GgoeYVh9GAplqs7iRm4GmxV3KB/Pyrf7ojapzqeVAmnJ5JBuopfuqh8On wJXb/bslCxpIhzxqlmNYIjeeWVCM2Z9JtRqPMC4sgh5iiLwNZZxdsGy8SjAwINMjelHo 4/mA== ARC-Authentication-Results: i=1; mx.google.com; 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 j3si12322980edj.448.2019.11.06.01.00.44; Wed, 06 Nov 2019 01:01: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; 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 S1728256AbfKFJAD (ORCPT + 99 others); Wed, 6 Nov 2019 04:00:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:56526 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726903AbfKFJAC (ORCPT ); Wed, 6 Nov 2019 04:00:02 -0500 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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