Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp581461ybi; Wed, 19 Jun 2019 04:36:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlNmWEQlujN6+olPxic4z3i2+h5ng7+3QQaHfFS3LLt8UasE2a9LCG/rcTLb5q4mvJl0P+ X-Received: by 2002:a17:902:2868:: with SMTP id e95mr4108205plb.319.1560944176143; Wed, 19 Jun 2019 04:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560944176; cv=none; d=google.com; s=arc-20160816; b=WHh3hl19lfzcX4zynsmXN7E+i6t79mxvkm7JCIjdQGnc+EtpNJKvGxq6uQjr5ML+Fm On27yv3U/eB9FCT7gtE2kvMR+Q96sK4zOov/GRK6Zz/kXlAF+UvF5aaQoBJcHFtIIHQK 5TrI/Y5MEPOycjo3t2AzlDKoALvjEMNdLhBH9Q82DEJl3HDnfHEfDX7P+Z1Dbudh/xZV +wNTqgpwWr+8HKtLA1QJE8b5HPHrgxIeBvbuhR89aQKdHXO8KfPlQ64uV6kFbTIpI0Ci Re0eq3Oa7rLyyoDYP6fnxK45bzvBeYoisb6+QO4P/uXP2TGOqVQOhUXHIHVrwJboPu8G 15pg== 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; bh=Bn5wuVuw5ttFYjKna5TVBWWZTz9A7nw6FCqvrm2qUhk=; b=Vfu02ubHc0BgOIsKE9rMdiobTenyz5BBzO6jKtTwYesREIMJK1iUd+mI6Gtwt+N/9u po2EWzCIHLmixzynL1MSsh4sDHr9TBKdDck+DjhmzvXEAIYguSVnovvr1otOvvFCCX+7 PVarRD82OI3+NAQNqIg3s1q856V/RMcu1zbp+7m1kwyjGKsbNYnnCBWAbkTO5Lde9g0f K0P4PRAAzSRS4pZ2BONJ5ZKpnXmN0ZhDflaf+/UP5yEyDKG9mUIjFmSAtJgQ5nupcok0 pJ3nRiMNUs3ddXEhiN72rrZtPP68IIm02P8PQr5fycgno8mDoZyFeZk+BtOYI2s8rpUk 7TEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bUp01ufs; 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 w3si2891403pgh.525.2019.06.19.04.36.00; Wed, 19 Jun 2019 04:36:16 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bUp01ufs; 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 S1731662AbfFSLf3 (ORCPT + 99 others); Wed, 19 Jun 2019 07:35:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52796 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbfFSLf2 (ORCPT ); Wed, 19 Jun 2019 07:35:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Bn5wuVuw5ttFYjKna5TVBWWZTz9A7nw6FCqvrm2qUhk=; b=bUp01ufsXgdhKtEN+BMzw3BnX qbpa3RCFVUzYH/bN6jaQJ3qNOnofXBOoQ6nrHS2bsnVfGGJZIgruFIX/49OoGYt+gPmyTGu2l57zg 5Ldv9cHUXg62QxrLLmuzFBQweFUq/jiPjZ2TlBJS+khPEcMPVt4nkj3vMgmcrSVkIodwLK33D8CkL h8XVlTUsBRnZgz/gg4/riDTv984g8aKrW4olO52/YLh5VTepUY+a/xgkrxuebLkgRB7sA2OJb4tGH QuajXADdl0a0hoVUhEs1/5Jp9LWPgJhmJ31Zjk1XWyqd1nC2Yksc1GHF+JocsSnyOUDXy4d+yT3W/ tCzzISpbQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hdYrt-0004jS-R3; Wed, 19 Jun 2019 11:35:09 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 56CEB20796503; Wed, 19 Jun 2019 13:35:08 +0200 (CEST) Date: Wed, 19 Jun 2019 13:35:08 +0200 From: Peter Zijlstra To: Miroslav Benes Cc: Jessica Yu , linux-kernel@vger.kernel.org, jpoimboe@redhat.com, jikos@kernel.org, pmladek@suse.com, rostedt@goodmis.org, ast@kernel.org, daniel@iogearbox.net Subject: Re: [RFC][PATCH] module: Propagate MODULE_STATE_COMING notifier errors Message-ID: <20190619113508.GP3463@hirez.programming.kicks-ass.net> References: <20190617090335.GX3436@hirez.programming.kicks-ass.net> <20190619112350.GN3419@hirez.programming.kicks-ass.net> <20190619113324.GO3463@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190619113324.GO3463@hirez.programming.kicks-ass.net> 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 Wed, Jun 19, 2019 at 01:33:24PM +0200, Peter Zijlstra wrote: > How's something like so: > > diff --git a/kernel/module.c b/kernel/module.c > index 80c7c09584cf..eba6560c89da 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -3631,16 +3631,28 @@ static int complete_formation(struct module *mod, struct load_info *info) > > static int prepare_coming_module(struct module *mod) > { > - int err; > + struct blocking_notifier_head *nh = &module_notify_list; > + int err, nr; > > ftrace_module_enable(mod); > err = klp_module_coming(mod); > if (err) > return err; > > - blocking_notifier_call_chain(&module_notify_list, > - MODULE_STATE_COMING, mod); > - return 0; > + if (!rcu_access_pointer(nh->head)) > + return 0; > + > + down_read(&nh->rwsem); > + ret = notifier_call_chain(&nh->head, MODULE_STATE_COMING, mod, -1, &nr); > + if (ret & NOTIFIER_STOP_MASK) It compiles _lots_ better with s/ret/err/ on. > + notifier_call_chain(&nh->head, MODULE_STATE_GOING, mod, nr, NULL); > + up_read(&nh->rwsem); > + > + err = notifier_to_err(err); > + if (err) > + klp_module_going(mod); > + > + return err; > } > > static int unknown_module_param_cb(char *param, char *val, const char *modname,