Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1062329imm; Wed, 18 Jul 2018 16:02:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeu2ZIQkTfBAuKoIKE4RG+yuDXidDw777oFHe008DJw6ZYiwWFZVtOrEj6SIp6TM6OEt/jF X-Received: by 2002:aa7:88d3:: with SMTP id p19-v6mr7051766pfo.160.1531954928075; Wed, 18 Jul 2018 16:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531954928; cv=none; d=google.com; s=arc-20160816; b=RqEB/81lMHbsRjW4wYtNjPBUPxF/psvM0kq4+pLkPbJTbk0mCqUS/B4Oo/GuoaVXVP N2imdbmyWl0ygqUmwvCFBnuZV6W2yZ161Z/MTonrbVNbyVZMdBZ17h8lidNM7TGG+Wl+ Pz3BcE/6dtDmCW6ITULODfZ0JdtcTg8ewFDf8/94CzpFs2i70b2FqvrsJI3AzlxBZeMX cDVqDwNTE+DverxFzd9Iq1lp/nc29d7kxIdsb3QEFKX66gOD9S9zjcvRUGdjUdyzDnIe 9u3cnzpDb7DSW8ybL4B4+uuCc8Y/mFsOe8SCvJ+aVGB1WBzx+n4IA90j7keyoL7eftq0 vOlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=OwRfXeF6NHIzrPioZ/8+JLBpzHWc2t/vrZ/aQ57UqDg=; b=Q0fbNollSnEDDNp48Kwv9YMIdV6t2SNxdZZx8a08Ocf5D+KskMsycPzUylEa1xH9+W Gor+EFlpX5r++1x/sY57t7AyWSEmq7nN8fHPlJClFlll1tYdD15uaIneLJK5ZVVutGC4 Yrqbz2KM5lHqJcARKsruEDDYWztRBab/EUHLJrNO+GpwVqepqYmkR9q5XjCAZ5sAI009 +7oSTBpf0M15WZ9L8oiLPaADKKJK9wBplnOzIrAWIjUAMLufMXaSdlkA79zKolRImVCB 0xallH9e2IcTDCNHVmo2wFTONC8gIHhcPB0MC3XtPNBimy2Lep8ptnYAzLscOQ1EV5nl Lbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=cF0Z4Cx3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15-v6si3980313pga.117.2018.07.18.16.01.52; Wed, 18 Jul 2018 16:02:08 -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=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=cF0Z4Cx3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730096AbeGRXjW (ORCPT + 99 others); Wed, 18 Jul 2018 19:39:22 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:41010 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729914AbeGRXjV (ORCPT ); Wed, 18 Jul 2018 19:39:21 -0400 Received: by mail-pl0-f67.google.com with SMTP id w8-v6so2684278ply.8 for ; Wed, 18 Jul 2018 15:59:15 -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=gxotVikXdl+MmIvW/DOt1gUiuZ0ER2km/RcVBpMflFx9mW8GMp6OwNuLRFt/6okFHD peMWmERcvssi7ITJon3URYyq1iV9nmVAWywiOwSN23YF5AJ5zO8hfZzUqYuTHpdF4m+6 MTD5wE0J7kXszWoGqr1gu7moTkWOchSGN8kxZA0hcFx6LL0nNK83DxjWhit0kk3OXl40 P4pGUa1kCcu8K5k26Q6FuST6ezOzqBYal7E24kMTuaO0oaDpqErAj0RI1vi6lMyApv7/ oS8fVxC0PNKbwgC7P+TBdPSyC2ROdyfI4Xqp4WSgYzUdrDMzxhCeuOYP98aot69Uf3m1 4tNg== X-Gm-Message-State: AOUpUlE/vLVkY5KM3CvAreGp5RXiMmDbL3ZCH7/o93cvizaXRR79pdLx 2LK1gnY3ZJSMDh9rQdV5bk4ppaL3E48= 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.18.0