Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3804064pxb; Mon, 1 Feb 2021 05:18:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJz572iTBjNJJ7XZFOrbVxR9E88dr/kNb0x2AbqbGKAOR/tc5gDYT5Lo9LIdC1beBQMdnRKc X-Received: by 2002:a17:906:5846:: with SMTP id h6mr17373651ejs.521.1612185522882; Mon, 01 Feb 2021 05:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612185522; cv=none; d=google.com; s=arc-20160816; b=qWjEV+VEfAiWMUg/B4w022RaE+wUFRwB7QZaXw19OMwIOjxbnSQEIr/FsHBgtooB1T WdcI0QwmQDi4rRSQVw0exd2+3k+w8smCD1Wd9p6yUHQgiE8AlKwkF0nVaYVHNpKAPBk2 sO2OOpHLwt45ZzKXcqNa0CNzLiOialkr0OwncmnTl52tGpJIE0Z07y54SnVgoGFufKtf 41ZMA4itRtek2y8z0YgLUOFKREp38teJfY27mXuhWE6WTIOLmD7sjonk3Y0ep6gmGLFr YgBfy7beHaw3i1tthF8zJSQmMM2tcY6pjZSsSnofT9U6+Ts40nqduZS6eX47F00406g1 XXNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=iG1ssvGNFlfcBERlblIGLRJrdg8w8dRIoVs/D4cvJVo=; b=dl2FMS7RiQ4fnzcwFnGU2a/0nqWBFXLg8oS5xpltTdWxCAZBBehdkOA2s5nNY9GCtH a4UTlIUJ/HT5Bz/BUIwGCh3CXmi1bM1ltgV+iV2q0YS0qLwnMVhW/YTDRvXEf5+wGs1O IjZNk6EVDOb2+xW42wKIo8/7ry/PIN9VGzwUol1MywKyvC24lViED1tAyEA4J9vwGGCX vQpzETy2SpqkarKkmUwJqcT6Urr1ZN0UqGEKpFWNQhOaCLQBQxGfKjPRel0iqCLyiDIw Vc1X63fgrFqbweWKf6ciIrJUSdUAJV4+F5KiFT/a9Dqm3ZLdhOBrQMChmd4QXMcQo160 QgOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy7si10810433edb.462.2021.02.01.05.18.17; Mon, 01 Feb 2021 05:18:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231838AbhBANRO (ORCPT + 99 others); Mon, 1 Feb 2021 08:17:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:39952 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbhBANQy (ORCPT ); Mon, 1 Feb 2021 08:16:54 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5380CAE9A; Mon, 1 Feb 2021 13:16:13 +0000 (UTC) Date: Mon, 1 Feb 2021 14:16:12 +0100 (CET) From: Miroslav Benes To: Jessica Yu cc: Christoph Hellwig , Frederic Barrat , Andrew Donnellan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Josh Poimboeuf , Jiri Kosina , Petr Mladek , Joe Lawrence , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, dri-devel@lists.freedesktop.org, live-patching@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH 04/13] module: use RCU to synchronize find_module In-Reply-To: Message-ID: References: <20210128181421.2279-1-hch@lst.de> <20210128181421.2279-5-hch@lst.de> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Feb 2021, Jessica Yu wrote: > +++ Miroslav Benes [29/01/21 16:29 +0100]: > >On Thu, 28 Jan 2021, Christoph Hellwig wrote: > > > >> Allow for a RCU-sched critical section around find_module, following > >> the lower level find_module_all helper, and switch the two callers > >> outside of module.c to use such a RCU-sched critical section instead > >> of module_mutex. > > > >That's a nice idea. > > > >> @@ -57,7 +58,7 @@ static void klp_find_object_module(struct klp_object > >> *obj) > >> if (!klp_is_module(obj)) > >> return; > >> > >> - mutex_lock(&module_mutex); > >> + rcu_read_lock_sched(); > >> /* > >> * We do not want to block removal of patched modules and therefore > >> * we do not take a reference here. The patches are removed by > >> @@ -74,7 +75,7 @@ static void klp_find_object_module(struct klp_object > >> *obj) > >> if (mod && mod->klp_alive) > > > >RCU always baffles me a bit, so I'll ask. Don't we need > >rcu_dereference_sched() here? "mod" comes from a RCU-protected list, so I > >wonder. > > Same here :-) I had to double check the RCU documentation. For our > modules list case I believe the rcu list API should take care of that > for us. Worth noting is this snippet from Documentation/RCU/whatisRCU.txt: > > rcu_dereference() is typically used indirectly, via the _rcu > list-manipulation primitives, such as list_for_each_entry_rcu() Ok, thanks to both for checking and explanation. Ack to the patch then. Miroslav