Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp42634imm; Tue, 17 Jul 2018 20:20:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdSmAeOY5kH+tBH6lrtEnH/Svcl92B0KfCwi5dSCudcPS6i4MKldoqGCE4GK224VJcdaP0x X-Received: by 2002:a62:5d55:: with SMTP id r82-v6mr3394004pfb.150.1531884011301; Tue, 17 Jul 2018 20:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531884011; cv=none; d=google.com; s=arc-20160816; b=A2J4hpd6kRvu9YFV7zCriBSVQEJCYu45p83HE7akKbsud84ceLNuPZLuQofd20kPv4 oMc+otVEICxDzRmGlFAVYvbENnW2G3zLexxeiX6n7fojMFB0664AZ1d/O1/FAxqOTZLK CnT2qlM5FyL7nJ+aO716Fw4yjIMhlYYnWo/u0X09JBRtk+O5yvEdd+lRxjiXw17FPol8 CXZ4fy/+e7z5Sf1RczDuGq28yMPpBD2oqHdkvcMIAS57X5vTaOU/5FwHgyq2kWMFuS01 0f69rdSa6oTGh2mLjpTc42OOVBNTU41kBY9yth17XQtONe+Tu1iFFr/re75mJ5BkiVAk kojw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=YJj7O6QzX0eMgHKDAIE8NQMr7YnFenCzwwSx4ixSNg8=; b=rBRytOwwfB37XyJee5C/+lvB8/iLmH5e2I5ImHO9TmxXIqJh/mmpryuZyUtc6OzIpF u8PoUH0kewLXtVogpoSmoQ3DmYe7N6A/R6CFXaUVGuq5HjLqHW+j+mD0Iw2TA7bKoXRu lAcnpCoUkbS7GUQgjzvdI8/vrKC9ZIYQwtpUwDc5ZyJ4T3zP74TJEeUlfV1uy0Q2CGMH M+AWORmWhikqaeRdb8FSis6sgk88XV81ee9rNTotIoktTkFV5z0Ay7sot+hRascbJug9 jIIPSAf8w3WeMs5U4vpdriJ7ArkPoMCdpt3r5boiLj+fiRxkLw57GlHhBTX9yz98t7pi p/0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b="DL/FqiY5"; 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 z3-v6si2153537pgl.579.2018.07.17.20.19.53; Tue, 17 Jul 2018 20:20:11 -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="DL/FqiY5"; 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 S1731402AbeGRDy6 (ORCPT + 99 others); Tue, 17 Jul 2018 23:54:58 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:46381 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730774AbeGRDy5 (ORCPT ); Tue, 17 Jul 2018 23:54:57 -0400 Received: by mail-pf0-f194.google.com with SMTP id l123-v6so1472557pfl.13 for ; Tue, 17 Jul 2018 20:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YJj7O6QzX0eMgHKDAIE8NQMr7YnFenCzwwSx4ixSNg8=; b=DL/FqiY5N0T6Qzi9hQxjKUD5bJGJRttNTLjSFszY5PFuegonZWVtyUTtvhlBX6SFPj XktvxdmTJ5SmUuEG/NJ+UcyVQodmwOsvVl/hdM++Zp47/6x3IHXy0WwjjdHfikM6bOcl uEQYNtaI9FxsCSwd/DUyUScbLgmwYnZ6Bs5/vCyf+VcQsA+vbbxrFKXByQHd6zt0/fNy 9C4Zow38Y8QrTm0MTATGJMcpxveutRMfvriNCI9sjJlqQRECpv8OsIKbbUD1J+k7VLSy q271bWzQih5wWNiK+WNzqMC6idFmskpoaz7OM6UbW1YQ6VwuLNsUn9nQ/ythc0JHKTCp TiTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YJj7O6QzX0eMgHKDAIE8NQMr7YnFenCzwwSx4ixSNg8=; b=QVPP5PFICL7jk5z15R1QVryqHTul5O/1TM54A9AqzuyafRwcLTjP/0FQPTjjp05eD8 VR1ZoVc4adLs6OdKqb7RKq0Fn+eCiEUhz6lC4WSKssm3oT41v6E4B7+D22hoXnDgAj8h iNo6GT9oO1YE1gdS/mZPs5xxvz4HU0SFYRYUKshAin5TWzUv/FUteiUorehQyZrcyU39 N3+BE5zKj7tJMKQiXaVbnkXmusIvSnlAUaXG+5gyHTJsCRFwbQkzrNh/q2cTXS1yp6Wt MChwsIvsKf2Dfr4dP7eGcQ4VFXP+dZebyfd3Uy9uld5xn3zwcf/ETCTUj1NrU9PwMsEx JSAA== X-Gm-Message-State: AOUpUlGhB2kfVCoQz9+IuV8vnvujU88MsYXg6ocneU3TrhOq5+wYm7J6 +pkYdDE/a38HYJ1UUnciQJXM1A== X-Received: by 2002:a63:788b:: with SMTP id t133-v6mr4031861pgc.329.1531883955913; Tue, 17 Jul 2018 20:19:15 -0700 (PDT) Received: from vader ([2620:10d:c090:180::1:bc4f]) by smtp.gmail.com with ESMTPSA id 13-v6sm397027pfw.131.2018.07.17.20.19.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 20:19:15 -0700 (PDT) Date: Tue, 17 Jul 2018 20:19:14 -0700 From: Omar Sandoval To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexey Dobriyan , Eric Biederman , James Morse , Bhupesh Sharma , kernel-team@fb.com Subject: Re: [PATCH v2 1/7] proc/kcore: don't grab lock for kclist_add() Message-ID: <20180718031914.GA29351@vader> References: <20180717193504.1d76fb1a43d0c8687d969143@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180717193504.1d76fb1a43d0c8687d969143@linux-foundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 17, 2018 at 07:35:04PM -0700, Andrew Morton wrote: > On Thu, 12 Jul 2018 17:09:33 -0700 Omar Sandoval wrote: > > > 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. > > > > ... > > > > --- a/fs/proc/kcore.c > > +++ b/fs/proc/kcore.c > > @@ -62,6 +62,7 @@ static LIST_HEAD(kclist_head); > > static DEFINE_RWLOCK(kclist_lock); > > static int kcore_need_update = 1; > > > > +/* This doesn't grab kclist_lock, so it should only be used at init time. */ > > void > > kclist_add(struct kcore_list *new, void *addr, size_t size, int type) > > { > > @@ -69,9 +70,7 @@ kclist_add(struct kcore_list *new, void *addr, size_t size, int type) > > new->size = size; > > new->type = type; > > > > - write_lock(&kclist_lock); > > list_add_tail(&new->list, &kclist_head); > > - write_unlock(&kclist_lock); > > } > > So we can mark kclist_add() as __init, yes? Yes, thanks, I'll add that in v2. > That way we save a scrap of ram and if someone starts calling > kclist_add() from non-__init code we get a build-time warning. > > --- a/fs/proc/kcore.c~proc-kcore-dont-grab-lock-for-kclist_add-fix > +++ a/fs/proc/kcore.c > @@ -63,7 +63,7 @@ static DEFINE_RWLOCK(kclist_lock); > static int kcore_need_update = 1; > > /* This doesn't grab kclist_lock, so it should only be used at init time. */ > -void > +void __init > kclist_add(struct kcore_list *new, void *addr, size_t size, int type) > { > new->addr = (unsigned long)addr; > --- a/include/linux/kcore.h~proc-kcore-dont-grab-lock-for-kclist_add-fix > +++ a/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); > +extern 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) > >