Received: by 10.192.165.148 with SMTP id m20csp3684768imm; Mon, 7 May 2018 17:20:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqN1NGFcQTIlI053l8fT3T1GABKq1DT07ImEyMxOkM2e7W2c/f8u7Ja9G0gjvy7cdXQwbS5 X-Received: by 10.98.3.3 with SMTP id 3mr37872314pfd.255.1525738850562; Mon, 07 May 2018 17:20:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525738850; cv=none; d=google.com; s=arc-20160816; b=LOAD0E6qy3RdgSpiVOLbz++IrgmrthzZjb0RxNABf+Ln/+X8iycepNBY93rju4Dfdu 3DibVfYVldUdhxcW1oEGVR1k3PuL2BqpqcBWcud1eleSGY3CKg01kQwfME4/G0x1YcPb 3yQbrPeNPfCRww12r8Z1GBYDeYkkpbUZuwm2nW83NBNhe0jQgZTE3KeA8vbliu90GfvO gpobgoUNkLJVtiFdEJTevac3/NNXo5Z0XBvUd9ZlKJQpaceTcMiAI3acxLMk6ROJWLXK ZyMVlhfqymmpXnGdo9CJxdo91Y8Zpbc1YefMJmJoQO/CZpEFjf32/YwHvcuHoJkRwhQT DI9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=EZ8FU7eOcfbLTiwz9UhK7+ZfzDepa5qD+Ry73oQTNKg=; b=BjF4hp6Tb0LulHnU81IiOnoyMVsuRU4hnWLjIVr+4fUkIRNnu8x7FOgGGFRmoXpBtJ zAFEf/E69ducmPz28rgASYaeT9EmesH9J8eRNsyi76hoJe0Js0hDEIyHJ4nIRc3yTXh+ 77DWYF7/nMTO4JBhuHQpHnmTqvBWxAI3AVKYLvnt7+haMZrsp4ZFxRnXKAflMpAzllRe acMrC1uSJgNP4HrtXJijmEGwzd2oFyTFbGqbsbMiQ3BWlC5z5aglAEx6EM4Krj1GyK6e 62wGQDh5+y8rnpf6S0tsr8FnmP8UN6IQHJ1vCHBcpH9cKqy3GMQcOcRWuI+sGAILphYT VNug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=JnAXwURf; 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 y5-v6si22102995plt.357.2018.05.07.17.20.35; Mon, 07 May 2018 17:20:50 -0700 (PDT) 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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=JnAXwURf; 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 S1753564AbeEHAUS (ORCPT + 99 others); Mon, 7 May 2018 20:20:18 -0400 Received: from merlin.infradead.org ([205.233.59.134]:55620 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753387AbeEHAUR (ORCPT ); Mon, 7 May 2018 20:20:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EZ8FU7eOcfbLTiwz9UhK7+ZfzDepa5qD+Ry73oQTNKg=; b=JnAXwURfBi5Iy/oMfWCIcnECGo rgtwC6JI5OrjXzkUljiXeslalXfg2rbfthnKvLpTmNkwd4na4Pi/rUtterfQ3qkniwlpFIWqfyYP9 YFLPLKZWaWEf9r1i5cigBf4WYQ8PyAePhsBk8tfs4s4NT5sx8tvrzwwUjSculQerl+65kq77QPEfF YvRbsflV+kiSn+cUvEcJHp4bCjPP0JoNSQj07DvCpLIFB3qeRRnhZ0dJzDk0QyH3St/l8+H34Qyv8 5BbdY5T1rZmyMcuKQRLuZCGZlqXQ6lqVdryC7CmkxHwlEBwO7hSwZfGz1DaFJV8hYwKej2Ws+S4rc cCNGONXw==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fFqMV-0008Pq-U9; Tue, 08 May 2018 00:20:12 +0000 Subject: Re: [PATCH] mm: expland documentation over __read_mostly To: "Luis R. Rodriguez" , tglx@linutronix.de, arnd@arndb.de, cl@linux.com Cc: keescook@chromium.org, luto@amacapital.net, longman@redhat.com, viro@zeniv.linux.org.uk, willy@infradead.org, ebiederm@xmission.com, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20180507231506.4891-1-mcgrof@kernel.org> From: Randy Dunlap Message-ID: Date: Mon, 7 May 2018 17:20:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180507231506.4891-1-mcgrof@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/07/2018 04:15 PM, Luis R. Rodriguez wrote: > __read_mostly can easily be misused by folks, its not meant for > just read-only data. There are performance reasons for using it, but > we also don't provide any guidance about its use. Provide a bit more > guidance over it use. > > Signed-off-by: Luis R. Rodriguez > --- > include/linux/cache.h | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > Every now and then we get a patch suggesting to use __read_mostly for > something new or old but with no justifications. Add a bit more > verbiage to help guide its users. > > Is this sufficient documentation to at least ask for a reason in the commit > log as to why its being used for new entries? Or should we be explicit and > ask for such justifications in commit logs? Taken from prior discussions > with Christoph Lameter [0] over its use. > > [0] https://lkml.kernel.org/r/alpine.DEB.2.11.1504301343190.28879@gentwo.org > > diff --git a/include/linux/cache.h b/include/linux/cache.h > index 750621e41d1c..62bc5adc0ed5 100644 > --- a/include/linux/cache.h > +++ b/include/linux/cache.h > @@ -15,8 +15,14 @@ > > /* > * __read_mostly is used to keep rarely changing variables out of frequently > - * updated cachelines. If an architecture doesn't support it, ignore the > - * hint. > + * updated cachelines. Its use should be reserved for data that is used > + * frequently in hot paths. Performance traces can help decide when to use > + * this. You want __read_mostly data to be tightly packed, so that in the > + * best case multiple frequently read variables for a hot path will be next > + * to each other in order to reduce the number of cachelines needed to > + * execute a critial path. We should be mindful and selective if its use. of its use. > + * > + * If an architecture doesn't support it, ignore the hint. > */ > #ifndef __read_mostly > #define __read_mostly > -- ~Randy