From patchwork Wed Jul 25 23:59:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10544939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8545C1822 for ; Wed, 25 Jul 2018 23:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EA2E2A9AC for ; Wed, 25 Jul 2018 23:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62FBC2A9CE; Wed, 25 Jul 2018 23:59:34 +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=ham 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 067BE2A9AC for ; Wed, 25 Jul 2018 23:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbeGZBNd (ORCPT ); Wed, 25 Jul 2018 21:13:33 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34132 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728339AbeGZBNd (ORCPT ); Wed, 25 Jul 2018 21:13:33 -0400 Received: by mail-pl0-f65.google.com with SMTP id f6-v6so3959557plo.1 for ; Wed, 25 Jul 2018 16:59:29 -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=uFyUSqGZcwUpvs/8kOWqA1xeN7gtaJ5Do2y1aq/Opn0=; b=qMJsK+nbeiwj3QxjU0RFGknPmtGyvXTJg274hVG1APprnfzdkWAz78Q8181S3Lb07+ 6P8wW2uhErXsPU0V5z2puQyAzRJVxgw3GdtpFTN2hA5SbgC9rDJ1AGR7ksWyz+eTC0Se 5UdYr0aFoDYt+XxYYqwZSh8/TFUQqOnFCgRdXJ7/ZvOTLw7D8b02SvBI7OlCpS5qXnjB dD1ZbfWb9ih8/F2siqgekm+cRRgcWwgGnOR7SSWNP1AE76q5+0c6/Ciexlst9/v1WnBc j4AADh2ysFMKjRBqpVLdRDMENC4WQhd+ToOmkX/yaie9JRmlWi3tMvRstaJqtv/cfLz7 D76w== 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=uFyUSqGZcwUpvs/8kOWqA1xeN7gtaJ5Do2y1aq/Opn0=; b=LZW71j7WucEsV6XUgj2su8BIydLmRUrgV7aQf4oUjfDp3GBx5EhrCxloeVjzIPcqNH 4dFL4Gs1VYm/Y+K00icvqru6Ru0/A9VkULmakBiNW0MMA5hFEVVbTjr3B88gnhWDiZ5M KFYG7YJm1YUhrYxYtv7n9JoHYwqPW7J5EACChzNO4escNOT9HnVRmDz5PJc4bvifNP8n NsuygGfjGbq78WTYgkV2dAMIG+gXgdywJIn9/FZdOSG/t2MYM/Hwv36cJUWQ35CFYZ4V kmgdKnujqnBGzm69SSYfiXKA0LMlYh/YZS2hwSutuGFxESjHsHHbvt6kJ5bf8qnGxi/M oryQ== X-Gm-Message-State: AOUpUlG8nvpsMI7UUIKJqAn+FlCK7K8utqm27ALFJyhjdBv3xEONSjcc rjmu9MBnH5Bo9vPJxcGDK+qDVg== X-Google-Smtp-Source: AAOMgpfUVbLhe2D3DOr0xi0xnNoeC8Pj2sFhNWZYRHSG2OzwyRqbIujvX7WGWYrAM0yqBxQp1m3TFQ== X-Received: by 2002:a17:902:e005:: with SMTP id ca5-v6mr22929578plb.224.1532563168526; Wed, 25 Jul 2018 16:59:28 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:8d38]) by smtp.gmail.com with ESMTPSA id 65-v6sm23188753pfq.81.2018.07.25.16.59.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 16:59:28 -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 v4 1/9] proc/kcore: don't grab lock for kclist_add() Date: Wed, 25 Jul 2018 16:59:12 -0700 Message-Id: <12f4b3dc5254547d12cb6669c45c533e647511fb.1532563124.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. Reviewed-by: Andrew Morton 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)