From patchwork Tue May 8 18:19:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 10387043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7F1636037F for ; Tue, 8 May 2018 18:19:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62C3C28EA2 for ; Tue, 8 May 2018 18:19:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56EE62915D; Tue, 8 May 2018 18:19:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20CBA28EA2 for ; Tue, 8 May 2018 18:19:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13A8B6B02DE; Tue, 8 May 2018 14:19:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0C43E6B02E0; Tue, 8 May 2018 14:19:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA6A26B02E1; Tue, 8 May 2018 14:19:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id A6EE46B02DE for ; Tue, 8 May 2018 14:19:27 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id u7-v6so2250341plq.3 for ; Tue, 08 May 2018 11:19:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=uIayc3HFJJC5cmtCcUU1gljf+DKjOmYd0skw1rsTgTM=; b=Tx6x/pqi20u27pa78lTS/3hENBvYHPbxOXZ0oaGUPfacgT1MJeuCO48RGxB8UuFrHp AVA6KUnJkhDCphThXA/Cj147PaCOufgT6iD+t/4oxqc8FLFJ3osFPtYO+AK8xZnjoSTV wA7aEdqCz3aajNEZrzKcJTMIvaNCaj84bTrZVtwInz7R35lFjQ/fyRn9oSYjjNcSeSzo UI7fthv0mQ1KGx1kFIzWCRxLhljPJV8CV8bHG9FlRRIDbZKMHHGTnFLdp0q0m+lfdDTq A18BzxS0aJa/PnKIBJ4WsrJb3kSUr8vS/zszAo7K8wneV75lc/Qng56VeWq9ZxkM+tIs g6SQ== X-Gm-Message-State: ALQs6tAlgpPV0BUa7awPfxUIBpfSpmn5e92+cWFWSbRxl/yx5wxu9494 gP6CiST+YK2PQhBz/fm0JfOZi8CIGCNIwsqZjlM1E4hIyErsOVNRtW0B9X9s0gBVLThYJzuBOWQ GRC/WURzBGzFfiqcqEE9YpnTOt8ehxvwQnYxBwsA88I5YH3/2FwhKSxD5GyXg3z9KjA== X-Received: by 2002:a17:902:4003:: with SMTP id b3-v6mr41530113pld.15.1525803567348; Tue, 08 May 2018 11:19:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoLDu93rIyMOmcvDyDE3ab8IbkhsXnPwZYVOroHchLbkmhhP6sdW97aJwNy0oRy95LMjvdx X-Received: by 2002:a17:902:4003:: with SMTP id b3-v6mr41530073pld.15.1525803566652; Tue, 08 May 2018 11:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525803566; cv=none; d=google.com; s=arc-20160816; b=k3EWciWMJKa7JJe8cIfg1ii/z9jZ0XeMzo38O1LNH7Xrbxi4EPLJx9TMKCQ+JV5aPP +/Q+YUKMhgkhviVe4uTXHN9J/Tm8bJAAZfDlQLVfP8qVp2BgtnwWcZ6sbIoieFwIxqYE t3zr8IjeYrDjPbFs3E/llbE9cC1BQIZwQnpa7ZDBwbvl/fsyg6d1dB80LqZU8T1HT+1G rVKqCnae66NRKVKK8s4C0VL4XXWVKYVLisKz1Y5mxq57MP1In1e3axzYryLcBDht+Bns YVzrnke2oDp2rqWpgDJje3d5qzpyqz3CQDDzX0Q4HD+pGfkH7kWHyIVRuES7u46AVTAP PltA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=uIayc3HFJJC5cmtCcUU1gljf+DKjOmYd0skw1rsTgTM=; b=TGDWOOkVl/90elL26NzM2EFUOkwvoPqE48eOIiljBnXo6G+ZQ9CdJzku101YutF+YF AWG5tskP43hpcLz121NHnXQqrkGPwTOu+3SyDR9x4KAkUgljldTx4NDysZG/hdWHpZ25 3VW/L8tjRSu7iroJ3HQDinqMzf/x8e+uOQueurfhlqQi90bALfQAsA3cAagW6+atsWkk 69W+dF7waVrj9BtJdFj0H0DSBfPccVi0Xmv7QEIVXUEjq0wU/nPPcK/li47BgWayceaj hqfBjVy6kKwisx1Irc6V9NrYneyS3fD6sX4zZATccf78exiaZy8Rf5k7pYdp+Cgj7c5V cpfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ebwxKS74; spf=pass (google.com: domain of mcgrof@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mcgrof@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id p84si24575850pfa.180.2018.05.08.11.19.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 11:19:26 -0700 (PDT) Received-SPF: pass (google.com: domain of mcgrof@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ebwxKS74; spf=pass (google.com: domain of mcgrof@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mcgrof@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 C53E921835; Tue, 8 May 2018 18:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1525803566; bh=BZSoJ8mcvx7jjB/0jAsBhVECKXm3cVNmr9e+lcsu7Ag=; h=From:To:Cc:Subject:Date:From; b=ebwxKS74vGE1SXWxMrrXs+OFtfgvFOL71ThgIH6t37J90qX7UNcUs0rPdxzZdZine sNUh6DRDZXdSjGnV2nk+jRbT7gHqM/TAdHmGQmE8mR7DA+2iU5rVqUHsBFONTUDqD+ pFxiCxAUaOFUib+tEHvbikT/WtAPZI9Q8YANukzg= 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, dhowells@redhat.com, willy@infradead.org, ebiederm@xmission.com, rdunlap@infradead.org, joel.opensrc@gmail.com, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v2] mm: expland documentation over __read_mostly Date: Tue, 8 May 2018 11:19:24 -0700 Message-Id: <20180508181924.19939-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.17.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: X-Virus-Scanned: ClamAV using ClamSMTP __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. Acked-by: Christoph Lameter Signed-off-by: Luis R. Rodriguez --- include/linux/cache.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/cache.h b/include/linux/cache.h index 750621e41d1c..4967566ed08c 100644 --- a/include/linux/cache.h +++ b/include/linux/cache.h @@ -15,8 +15,16 @@ /* * __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 of its use. + * ie: if you're going to use it please supply a *good* justification in your + * commit log. + * + * If an architecture doesn't support it, ignore the hint. */ #ifndef __read_mostly #define __read_mostly