From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7346DC433DB for ; Mon, 1 Feb 2021 12:11:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29D4864E9E for ; Mon, 1 Feb 2021 12:11:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231376AbhBAMLh (ORCPT ); Mon, 1 Feb 2021 07:11:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:57964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbhBAML3 (ORCPT ); Mon, 1 Feb 2021 07:11:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7928C64E2C; Mon, 1 Feb 2021 12:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612181448; bh=VpXCDfyNDkFB6N2oS+yv9UYv1FFtVEhcO5B6o8eybU0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HaH7mujAr3wAdUU7Wbx8NZL1I+ehA6nkr8Ywa4kIYDvUwHUoZx2E28Pxr7ifUj0mt 7ljJAQsR2C8cmJAhCEfFz7WlBbFbcYk6h1CXB2Y9PzQv9yo4WszIpL5OHIbr+huud/ DTJ+YupZxs4692+MeXtltnemY6HxUucQSaELW53wykG+dmhx/UvhvmlITS+Idy3evG 6qzrY4zJuBmI9bQgKtqj9S8Vxz3ss0nQSNYmw9hIaMuF6P5GYtPl/DuUcSxMjQJcLy tT307SwHtzy9d8kG545Zqjsb+38DqN6yFxfRVMnwI9dVoBzO/0f1HxxpxD93Q+NZid 37O97iC4kLFKA== Date: Mon, 1 Feb 2021 13:10:37 +0100 From: Jessica Yu To: Miroslav Benes 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 Message-ID: References: <20210128181421.2279-1-hch@lst.de> <20210128181421.2279-5-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-OS: Linux gunter 5.10.9-1-default x86_64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ 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() From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF83C433E0 for ; Mon, 1 Feb 2021 12:17:29 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 06C1F64E9C for ; Mon, 1 Feb 2021 12:17:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06C1F64E9C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DTn524J9NzDrRR for ; Mon, 1 Feb 2021 23:17:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=jeyu@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=HaH7mujA; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DTmxS0JG9zDrQj for ; Mon, 1 Feb 2021 23:10:51 +1100 (AEDT) Received: by mail.kernel.org (Postfix) with ESMTPSA id 7928C64E2C; Mon, 1 Feb 2021 12:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612181448; bh=VpXCDfyNDkFB6N2oS+yv9UYv1FFtVEhcO5B6o8eybU0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HaH7mujAr3wAdUU7Wbx8NZL1I+ehA6nkr8Ywa4kIYDvUwHUoZx2E28Pxr7ifUj0mt 7ljJAQsR2C8cmJAhCEfFz7WlBbFbcYk6h1CXB2Y9PzQv9yo4WszIpL5OHIbr+huud/ DTJ+YupZxs4692+MeXtltnemY6HxUucQSaELW53wykG+dmhx/UvhvmlITS+Idy3evG 6qzrY4zJuBmI9bQgKtqj9S8Vxz3ss0nQSNYmw9hIaMuF6P5GYtPl/DuUcSxMjQJcLy tT307SwHtzy9d8kG545Zqjsb+38DqN6yFxfRVMnwI9dVoBzO/0f1HxxpxD93Q+NZid 37O97iC4kLFKA== Date: Mon, 1 Feb 2021 13:10:37 +0100 From: Jessica Yu To: Miroslav Benes Subject: Re: [PATCH 04/13] module: use RCU to synchronize find_module Message-ID: References: <20210128181421.2279-1-hch@lst.de> <20210128181421.2279-5-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-OS: Linux gunter 5.10.9-1-default x86_64 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Joe Lawrence , Andrew Donnellan , linux-kbuild@vger.kernel.org, David Airlie , Masahiro Yamada , Jiri Kosina , Maarten Lankhorst , linux-kernel@vger.kernel.org, Maxime Ripard , live-patching@vger.kernel.org, Michal Marek , dri-devel@lists.freedesktop.org, Thomas Zimmermann , Josh Poimboeuf , Frederic Barrat , Daniel Vetter , linuxppc-dev@lists.ozlabs.org, Christoph Hellwig Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" +++ 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() From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3C09C433E0 for ; Mon, 1 Feb 2021 12:10:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6DDD764E9B for ; Mon, 1 Feb 2021 12:10:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6DDD764E9B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A9C1E6E523; Mon, 1 Feb 2021 12:10:49 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C3CC6E523 for ; Mon, 1 Feb 2021 12:10:48 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 7928C64E2C; Mon, 1 Feb 2021 12:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612181448; bh=VpXCDfyNDkFB6N2oS+yv9UYv1FFtVEhcO5B6o8eybU0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HaH7mujAr3wAdUU7Wbx8NZL1I+ehA6nkr8Ywa4kIYDvUwHUoZx2E28Pxr7ifUj0mt 7ljJAQsR2C8cmJAhCEfFz7WlBbFbcYk6h1CXB2Y9PzQv9yo4WszIpL5OHIbr+huud/ DTJ+YupZxs4692+MeXtltnemY6HxUucQSaELW53wykG+dmhx/UvhvmlITS+Idy3evG 6qzrY4zJuBmI9bQgKtqj9S8Vxz3ss0nQSNYmw9hIaMuF6P5GYtPl/DuUcSxMjQJcLy tT307SwHtzy9d8kG545Zqjsb+38DqN6yFxfRVMnwI9dVoBzO/0f1HxxpxD93Q+NZid 37O97iC4kLFKA== Date: Mon, 1 Feb 2021 13:10:37 +0100 From: Jessica Yu To: Miroslav Benes Subject: Re: [PATCH 04/13] module: use RCU to synchronize find_module Message-ID: References: <20210128181421.2279-1-hch@lst.de> <20210128181421.2279-5-hch@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-OS: Linux gunter 5.10.9-1-default x86_64 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Joe Lawrence , Andrew Donnellan , linux-kbuild@vger.kernel.org, David Airlie , Masahiro Yamada , Jiri Kosina , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Michal Marek , dri-devel@lists.freedesktop.org, Thomas Zimmermann , Josh Poimboeuf , Frederic Barrat , linuxppc-dev@lists.ozlabs.org, Christoph Hellwig Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" +++ 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() _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel