Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp358893rdb; Tue, 19 Dec 2023 21:28:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZAoVNbBBYzlPK2mIjY9vCyNKB/3NzOUFNtUbTrcQak3hZ+XaPo2tYbkaI/quKPD6UQDsz X-Received: by 2002:a05:6a00:2fd1:b0:6d8:53f7:e2dc with SMTP id fn17-20020a056a002fd100b006d853f7e2dcmr2562568pfb.6.1703050114132; Tue, 19 Dec 2023 21:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703050114; cv=none; d=google.com; s=arc-20160816; b=xBWHRm+h0lyPBBlOh/U6D0zTsUcN9p0KUdRg0vSIRReRRFRsWctrVltJN3Knp6ginz ftgamcAizyCYTMuowZZ4Hqi9hZAMM2rq3+xM8GzW5qgawD9exgMTS+xIuo/f5Rmd1zXp MYGjG7097C/3+EM1IL1tEYxO8wBOlqB9eamZAGXcQuh90wzdXPx1cWVIeyr2rd8xSQrE 9I6N6iYW3wrHUmSvAW9SrifD9P+OSwELJp0ac99nVixjXFiyJNZ1NY+TWT/Sj6MKG3Tj rGVVCu3WMJ8qcLgLUUbPD3BDOJzlDkV0u2lZWe9LuTLx1Xlk4EJx1RYZGBbmkZ8uVoH8 /4vg== 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=7t4oKzBXxs8IhkvTviWL7SIqcyen7yCKCslSyKINufs=; fh=tvBKSwNaMpZl5CnL0kvNfsjE6/LPUY27kRwpIfpKwkA=; b=eSDSXSFtc8HpKjst9zXtacrPJD0wvf9CysWyB2IcX7uX6raE8KJHbHzPqZOXQXUsm/ DP638jgngB8nlS2u0qdcMq9+oVoWr22mjS4iVfhmdAe4CPVN4amOSMtg/4dsVh8jlcY8 EFO6c7KPW+AnWoW1nN6dcDFb0sQ/doIeJi9asPY6VpegoOiIXzNrGtzGkyQFqlcvEXsZ bgIDrWMWTcH2EMVr5GfDQ6bh+7Ma2n9khI0V4X/ajK/nYkbXFeOTUsSHrGfrTzbmvFir Tqpcls6Xa07DrDvIonBI3o9myZi5zyALKDKwVY5IV+HHM0oI1U11Hjk9Z9ifE99E8MkY Zg3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-6383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6383-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 ko12-20020a056a00460c00b006d09877dca8si16130000pfb.60.2023.12.19.21.28.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 21:28:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6383-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-6383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6383-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 C60312883B2 for ; Wed, 20 Dec 2023 05:28:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01AAD101CB; Wed, 20 Dec 2023 05:28:11 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 1B4B814AA4; Wed, 20 Dec 2023 05:28:07 +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 szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Sw2Bn3bZMzWjwP; Wed, 20 Dec 2023 13:27:45 +0800 (CST) Received: from kwepemd100002.china.huawei.com (unknown [7.221.188.184]) by mail.maildlp.com (Postfix) with ESMTPS id C9271180032; Wed, 20 Dec 2023 13:28:04 +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; Wed, 20 Dec 2023 13:28:03 +0800 Date: Wed, 20 Dec 2023 13:27:51 +0800 From: Changbin Du To: Luis Chamberlain CC: Andrew Morton , Changbin Du , , , Hui Wang , Xiaoyi Su , Jeffrey Hugo Subject: Re: [PATCH] modules: wait do_free_init correctly Message-ID: <20231220052751.3zcnsnvjk5vf5t7j@M910t> References: <20231219141231.2218215-1-changbin.du@huawei.com> <20231219125151.4a042a259edf3c916580ccfe@linux-foundation.org> 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: X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd100002.china.huawei.com (7.221.188.184) 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? Cc Jeffrey Hugo > Is it perhaps for an out of tree driver that did something funky > on its module exit? > > As per Documentation/RCU/rcubarrier.rst rcu_barrier will ensure the > callbacks complete, so interms of determinism both mechanisms will > have waited for the free. It seems we're now just limiting the scope. > > This could also mean initialization grew used to having RCU calls on > init complete at this point in time, even for modules, and so localizing > this wait may now also introduce other unexpected behaviour. > > Luis -- Cheers, Changbin Du