From patchwork Mon May 7 23:15:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 10384945 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 A6F9260353 for ; Mon, 7 May 2018 23:15:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90DF928B7E for ; Mon, 7 May 2018 23:15:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80F7428B88; Mon, 7 May 2018 23:15:11 +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 1A0F428B7E for ; Mon, 7 May 2018 23:15:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE5126B000D; Mon, 7 May 2018 19:15:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B6D1E6B0010; Mon, 7 May 2018 19:15:09 -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 A0FD06B0266; Mon, 7 May 2018 19:15:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id 5B0B86B000D for ; Mon, 7 May 2018 19:15:09 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id u10-v6so8161856pgp.8 for ; Mon, 07 May 2018 16:15:09 -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=N3RZH3u6D8HXIQ3cZpo3nwSDvJznilzSXBVOP5T3a0E=; b=BE5TcgT9KfNxTKK028Y3Q0bwryn393FBCYPC1YYSfjj66lN2Mytj6tao7UTIhytdPv n8FmMiD+fyAb4e7uwFdMfAk7JSW/OPTY3+nGIVimjcy/CS6U2SeEjdoSA0+/bTv0H2NF k72pAuN1F7VOIg88jGKc7sz98vpicqfGefspzxxRbsxPI3zQ0SD3VSlnMShfdw3GPHzm AYIhfb/GTs+trCHP87c3vz5WKZkFYy219oB6ew5x5un/11n1SibMeg7Je7cJy76bqgb5 mes2vDsMwIq/bCaBanAc0pcG4jZeNWsTENKF91JZmL1cu/mJjL7uNH55tpg3e2X0vdP/ EInw== X-Gm-Message-State: ALQs6tCkgw5q1gK9SQXJFu9JK6UqWWbgIJGvL6DlrAnMyOdV7SbBBay9 sGB9mjLVMxfVSrxwiqAiGtwui6kGsNnmghOF+PoWSOMwolKcpgYBEdIT+LGs8f8fbJEEejYp9Zn /rv+uOf48GfpUNcMHFWEc0ldZVx8KKacKp/5k11pR1XsTe1e97srwEr7v2JP+zQ8VuA== X-Received: by 2002:a17:902:3343:: with SMTP id a61-v6mr28720107plc.241.1525734909019; Mon, 07 May 2018 16:15:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLmxG9Y/S13CEj4PoS4lFkM9797V5TeelY4OYrIMDT8wANCBNFfi5g8IEnOQTMhdVbraBu X-Received: by 2002:a17:902:3343:: with SMTP id a61-v6mr28720076plc.241.1525734908268; Mon, 07 May 2018 16:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525734908; cv=none; d=google.com; s=arc-20160816; b=i9/jTxMMhKc3SqRwi//w2XKI1HVFhPPSBQh3tGVh+LlmTjohJQVxNDQpmLPT7VGrNr sbUChSGTzctzDxRjxNuIWs97PvDVT78wC/UF9lKc1qP4G2AfxiyYQM8ZdiwLWZjF536p V0sX4jcxElVfKOB8MmqgCKE/oQKEdgRv/OOBQLzeUeMk9IXQwiU8dN10DEUuq7mO9Icc gRypGgp/wsLI4g2ETOJQNrg8KuSwg5xOW/A5NNF/Nt0KgBtqM0q8EHn9OiPNbpbmQ52p hF77GsuQVNUGEMjizCQerufmZBgCAP+BmDs5eTwiRqLJBYljLdsQQAoPEeStUE0Iv5cs +pUg== 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=N3RZH3u6D8HXIQ3cZpo3nwSDvJznilzSXBVOP5T3a0E=; b=GYPkEQVRIyk5f1vVjmIpuU+XDV9bFtTKJEdgPLhBYuPKYxR1sHRy0ef3otqGibrDAK FKIrjVcrzUZfiHnTRBEqwTQ085VqWRqP49l7Dyba+dpkX7o4PmYLtzPJI+PkW6/Kgsz3 uuOqYlTmfXf/TVcljkA7KvkIQG0WqeuQsA2NWcYwuo7DGETs/sKSLSqUinu1XdD3IZpl dv3JhSAQ6fYQn5mxEMpC15ZqKXQz7GArvSFJOxlN7B3Bfu8tItqqjLN3l63VqeqGKhG1 FphBYK7oJphoCsHQes3qSAqPBu/ZbKTk7RMJKT5/Rnm+c1sXvcnrYNr/y4M4si2xHY/c ZtiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0qSRCEzG; 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 x4-v6si10427592pgr.301.2018.05.07.16.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 16:15:08 -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=0qSRCEzG; 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 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 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. Signed-off-by: Luis R. Rodriguez Acked-by: Christoph Lameter --- 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