Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2138359rdb; Sun, 24 Dec 2023 20:08:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUnD2kw9MP46luWh/UuMGkT2xjwUlVDW0+W99y+b1Kf8roL3UJK2wpuY8vdTHiq2fe2qjo X-Received: by 2002:a05:6871:6111:b0:203:2170:303a with SMTP id ra17-20020a056871611100b002032170303amr5237839oab.80.1703477280810; Sun, 24 Dec 2023 20:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703477280; cv=none; d=google.com; s=arc-20160816; b=Bj15mTZyiXUy3HxPRsyMXaIK4bhGl1B4ZLneMC3+dK5rhy8/MSjvZSYux13E/ZeRqN 6o5GYj8Go/wku0F3/qhUSmL/zRyorHRamTzI4SN3BkMDkKvajg4dNhuxhnwsK99YTXVF HIw3OjnwR5msJlBr8SufrqeOTRYQ8r2y+sJ59otBpl+JIEPqoom1GLZq/vgXfHf6RQ7+ lAESPwf7XGYxHlF/bRXNksH26mmwthA/oDs3qI7jRwaOAk+yRGKv5nosjQLrLDnlCzkP 9uPT4BbQVTZkAPsIEG3t7++m8QpAMSQjIVgryFPMTdQTvElBL4rWIoaymXVIJ6fhnlm6 IutA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=c7AJnKyIqLRT91QAX81oArVEjPAHd0QQwB7VW87bDeU=; fh=42Z88SkRRrcCE1dCP4FeZtQnj2A+X9OZUwHLZjqyYmU=; b=oyWE+XySH5hHtcWAJDSnGavf20uYm4SciZRpN5cPtQV+Xe4eq4G/O8Cocs9pc3AVA4 jufk9LRyxHPwo1eqPfdi8NhOANfqpOKs/kyM2eXVV7M5A+Atw2vGw1zBAU3J52G/Ew+1 4NRraFZeU/5RIHbAHtub+lR8bX5r3Q9xJvDebHWVaZ4OGsinEDh0VyQwz+CUxCFt754w 6CgJCN2fgPRiarxbrp0gMX1/laeG2afEuxiLaSctzWJpzvSwdKdN2+kk1yFRrh/Nvc20 y+nZtHPSbp+1a3AcOknLF+bbUfG2cnDnH6MkgM+hLvPrfHlEq47S9emwQ4B8gcx1dEdk g6zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e9-20020a636909000000b005ce0be7965esi2539646pgc.467.2023.12.24.20.08.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 20:08:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10886-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6E077281ACC for ; Mon, 25 Dec 2023 04:08:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E12CAED5; Mon, 25 Dec 2023 04:07:53 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78813A34; Mon, 25 Dec 2023 04:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Sz4941FZ0zvSLb; Mon, 25 Dec 2023 12:06:48 +0800 (CST) Received: from kwepemd100002.china.huawei.com (unknown [7.221.188.184]) by mail.maildlp.com (Postfix) with ESMTPS id A974A180076; Mon, 25 Dec 2023 12:07:47 +0800 (CST) Received: from M910t (10.110.54.157) by kwepemd100002.china.huawei.com (7.221.188.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Mon, 25 Dec 2023 12:07:46 +0800 Date: Mon, 25 Dec 2023 12:07:36 +0800 From: Changbin Du To: Changbin Du CC: Luis Chamberlain , Andrew Morton , , , Hui Wang , Xiaoyi Su , Jeffrey Hugo , Stephen Rothwell Subject: Re: [PATCH] modules: wait do_free_init correctly Message-ID: <20231225040736.7htp2cfhocbw4hxw@M910t> References: <20231219141231.2218215-1-changbin.du@huawei.com> <20231219125151.4a042a259edf3c916580ccfe@linux-foundation.org> <20231220052751.3zcnsnvjk5vf5t7j@M910t> <20231221023037.emexvbbnt6tpgcs5@M910t> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20231221023037.emexvbbnt6tpgcs5@M910t> X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd100002.china.huawei.com (7.221.188.184) On Thu, Dec 21, 2023 at 10:30:37AM +0800, Changbin Du wrote: > On Wed, Dec 20, 2023 at 06:32:39AM -0800, Luis Chamberlain wrote: > > On Wed, Dec 20, 2023 at 01:27:51PM +0800, Changbin Du wrote: > > > On Tue, Dec 19, 2023 at 01:52:03PM -0800, Luis Chamberlain wrote: > > > > On Tue, Dec 19, 2023 at 12:51:51PM -0800, Andrew Morton wrote: > > > > > On Tue, 19 Dec 2023 22:12:31 +0800 Changbin Du wrote: > > > > > > > > > > > The commit 1a7b7d922081 ("modules: Use vmalloc special flag") moves > > > > > > do_free_init() into a global workqueue instead of call_rcu(). So now > > > > > > we should wait it via flush_work(). > > > > > > > > > > What are the runtime effects of this change? > > > > > > > > Indeed that's needed given how old this culprit commit is: > > > > > > > > git describe --contains 1a7b7d922081 > > > > v5.2-rc1~192^2~5 > > > > > > > > Who did this work and for what reason? What triggered this itch? > > > > > > > Seems the waiting was introduced by commit ae646f0b9ca ("init: fix false positives > > > in W+X checking"). > > > > > > As what I have observed, mark_readonly() is only invoked by the first user mode > > > thread function kernel_init(), which is before userspace /init. So is it real > > > possible we have loaded modules at this point? > > > > Are you saying we don't free any module inits at all then? I asked a lot > > of questions and your answers seem slim. > > > Yes, indeed no module loaded at all before mark_readonly(), at least on my desktop. > So I think we can just delete this synchronization. I am not sure whether there are > any historical reasons. > I thought about it again, kernel doesn't prevent any drivers from calling request_module() before init. So it's possible that some particular modules do behave this way. I will send an updated one to fix the compilation issue for no CONFIG_MODULES. -- Cheers, Changbin Du