Received: by 10.192.165.148 with SMTP id m20csp3640076imm; Mon, 7 May 2018 16:15:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrM8/eEl1f+OlmLscuwmMJm0wmgyCx7FKPbC7x1j31fQNwWvBBMKDm4Ox5IjFtL0+AuVS4a X-Received: by 10.98.82.129 with SMTP id g123mr15168015pfb.22.1525734935186; Mon, 07 May 2018 16:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525734935; cv=none; d=google.com; s=arc-20160816; b=eRdnU2AGJGrkBybkk0CZrtysdCmEk6FLyEMBS2GRnhij3LXsHTNNY2MYbsgPW4dqYn +jjfgiSFBPocQbRRShjAssnF766pBVnMFCE6ZgyA/Za1BnuT6vHHl5N4j010WQBQ4JXY 0Z1oTh53A4fAAjLke0U2xdRiJX3Q0ErplAJHAmQmKG060VwLqJ9d4o18AOGlL9Df7zCs B4DNoy+b1ZeKHRaMHas0CrA1idjsRCDUTr3XUl0SdsEj1iRgjDWsLjQ8l1ivdpvg/6wh XuCh6qfoVxvgBSRsj0KVzXxqlMpwz43qcbPrbo/akEvsQVqjzAe6NhfPu7XygyKWsgbG Iesg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=N3RZH3u6D8HXIQ3cZpo3nwSDvJznilzSXBVOP5T3a0E=; b=WDTaOFI+YXez/hmgaZ7tGARubkScLZDIA6wnk894bFDP68oT4YheqS4KIBKoao3j0F iA6rX6oyzRXmqCEWp0KWniBlUtPYuv0O9lWCMAkKlu/WpIbWLLPbpWyiUjWJ6rNTkXtK 5DgfPt4Ek7PEj0u3Np84sybwTph7SqxjSmkeLumi3DHmPVW0q+iGTN1flM28Ixe1NbWy xBFtRQAlgwHF1QATyINpB6B+1fjOoP1IslH+6aYPyyt+NlNpkLQPtyh9qLQLYbetlnlr nqb2L/XPlMHcLbKmDh7wrSnkVdqckFTjMfMY6kPqIiclXhvDsfNkYdC8VkRnqF9nQ73/ 8ibA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0qSRCEzG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r126si10055179pfc.202.2018.05.07.16.15.20; Mon, 07 May 2018 16:15:35 -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=pass header.i=@kernel.org header.s=default header.b=0qSRCEzG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753321AbeEGXPJ (ORCPT + 99 others); Mon, 7 May 2018 19:15:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:54080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752773AbeEGXPI (ORCPT ); Mon, 7 May 2018 19:15:08 -0400 Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 65CA220740; Mon, 7 May 2018 23:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1525734907; bh=2anjXUZcx6SEqhpISnyNME6P//mCb/5r2ma4INFp/EE=; h=From:To:Cc:Subject:Date:From; b=0qSRCEzG3Dj/n8Whii0fDFe6fz4jgJ+QXzA1v8RcjRFDsV/kPXHVYkNcNjxZ8ZuZG nGJoMFio3WhpUUKwM6oUyKZnSGUDElZG5T4A/KiumlSj057wP/mMOP5SexqJkrqE3M q/AqYbuN2xwuZTmCeRkToJY1LJOKs31s82P+tloI= From: "Luis R. Rodriguez" To: 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, "Luis R. Rodriguez" Subject: [PATCH] mm: expland documentation over __read_mostly Date: Mon, 7 May 2018 16:15:06 -0700 Message-Id: <20180507231506.4891-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __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. + * + * If an architecture doesn't support it, ignore the hint. */ #ifndef __read_mostly #define __read_mostly -- 2.17.0