From patchwork Wed Jul 18 22:58:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10533415 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 05482600F4 for ; Wed, 18 Jul 2018 22:59:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC152298AF for ; Wed, 18 Jul 2018 22:59:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E063E298BD; Wed, 18 Jul 2018 22:59:27 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A5BD298AF for ; Wed, 18 Jul 2018 22:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729973AbeGRXjV (ORCPT ); Wed, 18 Jul 2018 19:39:21 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:34844 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbeGRXjV (ORCPT ); Wed, 18 Jul 2018 19:39:21 -0400 Received: by mail-pl0-f66.google.com with SMTP id w3-v6so2692178plq.2 for ; Wed, 18 Jul 2018 15:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OwRfXeF6NHIzrPioZ/8+JLBpzHWc2t/vrZ/aQ57UqDg=; b=cF0Z4Cx3o1pCQgXtmovhU7GvX2yWA2470gy8ygcUifBPiMV49ps2S/3XwQK36MEvJW ioSwSl3mwSHd1s99wPwODReKgJ54EoLrbOteUKA8jmtFgkuwJofr+syvG2TtNYc7nLO9 OVl0lzHIrOnwn6vikXOl3cUhAPSuVBLyL0OeKCRCH+6FKZMFWeZTWxDZO2iLufo7VKSL NkqEc16S6JR4Oa+0hQLoqq2zFjrvY47J0aH+DQvx0AMhkbp6j9j82wnsOcl+9TtazkjV xjSElo5ezFmZdJBgGNqKvQhCigNa6KuN7zYtCEHxNZkgIIGb2GU9vqmc2sDFSUYd8diF e+pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OwRfXeF6NHIzrPioZ/8+JLBpzHWc2t/vrZ/aQ57UqDg=; b=ftorNcGY3iEhvvWWOun0+jdyU5uiwtEmR1GyPD7JCvmmQbmiVc8lfNs3JRqwkzAWxc b9TpBitjjqxmDnvC7/SFqSPRrCV28oSeL5YmOwA22nOcTQ7xhb/rONXSTWEP13EiSzVz fNNJUheTr0o9R2TFGGHGE/NgoZ8OpIe4J22/vVe5GahyZJaxKvM4Rw0dCeRxf08KQJwh ldg0kvA9eq1um3HasKLxqz7uub/MDhiDohmXT3MNy0hNbL5p8Aw0eyUPsRgUUCwu2bHl 16kwXBDp3COldctvDa3uVKMg2eM7/LzijnWMQ9plL139rzFY3KpoUKK0BWg9GXKJplCp XC/g== X-Gm-Message-State: AOUpUlE2qqC5Bt8W5Su/yelP6JbTzQV2tRAh28pLMAp/i8oA4NTceUk2 VDkJZn9qspbmmDNLWDNsw+KcJQ== X-Google-Smtp-Source: AAOMgpeYVGw86XzdZa5L442PRAu081YO9Wzf6lGPvdlkVE2ffqFRj1adxaKZWsCr4wMe1FO4P+jjVg== X-Received: by 2002:a17:902:262:: with SMTP id 89-v6mr7643504plc.221.1531954754505; Wed, 18 Jul 2018 15:59:14 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id s16-v6sm6377946pfm.114.2018.07.18.15.59.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 15:59:14 -0700 (PDT) From: Omar Sandoval To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton Cc: Alexey Dobriyan , Eric Biederman , James Morse , Bhupesh Sharma , kernel-team@fb.com Subject: [PATCH v3 1/8] proc/kcore: don't grab lock for kclist_add() Date: Wed, 18 Jul 2018 15:58:41 -0700 Message-Id: <98208db1faf167aa8b08eebfa968d95c70527739.1531953780.git.osandov@fb.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval kclist_add() is only called at init time, so there's no point in grabbing any locks. We're also going to replace the rwlock with a rwsem, which we don't want to try grabbing during early boot. While we're here, mark kclist_add() with __init so that we'll get a warning if it's called from non-init code. Signed-off-by: Omar Sandoval --- fs/proc/kcore.c | 7 +++---- include/linux/kcore.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 66c373230e60..b0b9a76f28d6 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -62,16 +62,15 @@ static LIST_HEAD(kclist_head); static DEFINE_RWLOCK(kclist_lock); static int kcore_need_update = 1; -void -kclist_add(struct kcore_list *new, void *addr, size_t size, int type) +/* This doesn't grab kclist_lock, so it should only be used at init time. */ +void __init kclist_add(struct kcore_list *new, void *addr, size_t size, + int type) { new->addr = (unsigned long)addr; new->size = size; new->type = type; - write_lock(&kclist_lock); list_add_tail(&new->list, &kclist_head); - write_unlock(&kclist_lock); } static size_t get_kcore_size(int *nphdr, size_t *elf_buflen) diff --git a/include/linux/kcore.h b/include/linux/kcore.h index 8de55e4b5ee9..c20f296438fb 100644 --- a/include/linux/kcore.h +++ b/include/linux/kcore.h @@ -35,7 +35,7 @@ struct vmcoredd_node { }; #ifdef CONFIG_PROC_KCORE -extern void kclist_add(struct kcore_list *, void *, size_t, int type); +void __init kclist_add(struct kcore_list *, void *, size_t, int type); #else static inline void kclist_add(struct kcore_list *new, void *addr, size_t size, int type)