From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2365442BC36 for ; Thu, 6 Aug 2026 09:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786007500; cv=none; b=F1I6tl/p9f62SLVA1QduE7wAQdzucVl4aJRSNunAuk55VJ3CIEBjAB5ZW/dPQp5fnC1f2gaFPe37DFouZaaMyR9T5QwWCg41RNQIyk4yhZ4qxo1ju7iasrmvnGTRW0GAjPuaUnpAsukmCGWWf9cewdkf37bNJnYm9jTnk+1090k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786007500; c=relaxed/simple; bh=382YaSX9VKY57gg5Zc2yIAoHK5TXIXYZe3M5xBZpkn4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nr77M+Nun2LOb6VowKE8nFd2L2OteMmEm6XFVI/3VsAY6g24Cd1cvzzvsRr7IKEpjFT5rRu219yTQQiZNVLx67WP3HxhcPNn09+qVF533pN3kPKl4P3eD7DIYuVf6WU6x/lpHtuR+F4uSMEDqCO2jEOdC1iauJDg3kOcLZhVfSA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=YTiesVAj; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="YTiesVAj" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-49802c418b5so18657125e9.1 for ; Thu, 06 Aug 2026 02:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1786007496; x=1786612296; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MvPkxu2M1aQJU5khje0h6+xkd+fbHQMlBQ/6GQVZV5w=; b=YTiesVAjxHtqmJmQIQFHLRfSiEAg0FhHVFoo5k1W6XJCE7k6yY6+UL1eN8O3BVQcuf Q2EIqu28hNYT31uDBj0KPLqBihY2/PjwZ1mi64pda2k08IUFGPoV9k181cMvoQFhc3NS SI+q5VpPzgoXCQYHQQ+NIFUv0wTckkxPacjHOBOfMV94sh4vu0c6LFNpyWw016oAy53+ CJANa1hskwIOWX5JKmekvE+k2J1p4/LTOMLZZsMRF+HNtEhq8/4J4twz9qgZjqdwpnAF lUebqI/chX7XBgFrUeIQFNyvqGH2uCdLM+1NQuXvxIlANVUpXwv6O1tEsa8rj281UmmA pDFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786007496; x=1786612296; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MvPkxu2M1aQJU5khje0h6+xkd+fbHQMlBQ/6GQVZV5w=; b=LeQNMB1lbtgjmZ1r3gqX8nSv0BtT5w3lu31gxVdaSqApCp5JYnyzDjveDAnEyatGZk YZRoOMLtsmHCa2IARdt0lK4OoguV0HhIFmXpa67AL4yCjqfwIfRN5RxZYet5u3+vjW1V 1F/rEC0eZkaj2OXfzeWxc0kSkU80Afh4NKyxz6KZTG5dOC3nXTiaNpoPHIuui4up3P1d IKQVRrZlCcwKfBF1s0iqDsLl5WPizCHnaevFdRNkP0SNBlBe4iZPf+E3A2rnF2itz5Xb 4jr3ALhaqwVvJW+Fv67c8Xm2q8vYh3wN8OmCYALTPuNHjkkLDM0ke5+NdQ7eKT/yXgM2 QCsA== X-Forwarded-Encrypted: i=1; AHgh+Rq8Gi8SMT72ZtvECEnT191EMbppuk/feg9R2lqLRwjbBOsrUoFMfFy+lmGUO1vpc9jeXhgYkJ7wq3On/IA=@vger.kernel.org X-Gm-Message-State: AOJu0YyZRpvcn3mFL0Ft67VZVw6/4dPw/NN8vfofa1Vp/Ohfiaq4/XSg 9bpq+xofcribZlbqYfvi9k8KKIipvSvpwtCrxCGLmsW4pxz28orb3OvU9x3mQbgAkN0= X-Gm-Gg: AR+sD12zaejBN5qlbPKnd8llJxnrOil32LijT/TtgR8lBut0o1yKfQNISy2dyh0jPMd 40vu3Rp78bgXxCjyY23UsNfHSMavyrFQWZW/LcAII4RZwdi7+LzL4RKYmWWgwRJW4HWYj3krpXx woWbdpimJoMkfUowuXVYGiFcujzeG72xvI8NNxa1InlcSAisTmOhh3t3CTtgUjikgVpQgPHL1LU aZw7gp3qAa99asAidOpwvs1Dgvi8K+aUNyllRVsJZtu+UlS0XDSuoJt8O4Tw2QU/nFc5ErGNxOo h98aGMs17q6itl2J+/cGXkT0Bmmph2BhTfXa0QGONNeTRgos4ZP/pP/DSOj8owb6hZ2WgpxJ3Xi cJE5Xn74nQTCIK/+vDN7198GiTBHnmFUE+fKaupOqjjJLDbZtQMjFBB0TFMOSHqeRAj8uGzfPxX CkfSsxxz3Z8lSLlp7C2EfcuVPAunlfjoJOLIBWHinQe1V7IyMV7uoDeb18dlx85Rf8gqE= X-Received: by 2002:a05:600c:1f86:b0:499:52ab:a50c with SMTP id 5b1f17b1804b1-49952aba5b3mr69266275e9.1.1786007496236; Thu, 06 Aug 2026 02:11:36 -0700 (PDT) Received: from zovi.suse.cz ([2001:af0:8000:1409:193:86:92:181]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4994e4c32e0sm93157095e9.0.2026.08.06.02.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 02:11:35 -0700 (PDT) From: Petr Pavlu To: Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen Cc: Aaron Tomlin , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/6] module/dups: Inform duplicate requests about the result directly Date: Thu, 6 Aug 2026 11:10:15 +0200 Message-ID: <20260806-module-stats-rcu-v3-1-2b0331106f00@suse.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260806-module-stats-rcu-v3-0-2b0331106f00@suse.com> References: <20260806-module-stats-rcu-v3-0-2b0331106f00@suse.com> 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="utf-8" Content-Transfer-Encoding: 8bit When kmod_dup_request_announce() announces the completion of a request_module() call to duplicate waiters, it queues a work item to invoke kmod_dup_request_complete(), and only that function calls complete_all(). This adds an arbitrary delay that is unnecessary and provides little benefit. Call complete_all() directly from kmod_dup_request_announce() instead. Signed-off-by: Petr Pavlu --- kernel/module/dups.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/kernel/module/dups.c b/kernel/module/dups.c index 8b6f8f177de4..45080f451e5c 100644 --- a/kernel/module/dups.c +++ b/kernel/module/dups.c @@ -48,7 +48,6 @@ struct kmod_dup_req { struct list_head list; char name[MODULE_NAME_LEN]; struct completion first_req_done; - struct work_struct complete_work; struct delayed_work delete_work; int dup_ret; }; @@ -93,29 +92,6 @@ static void kmod_dup_request_delete(struct work_struct *work) kfree(kmod_req); } -static void kmod_dup_request_complete(struct work_struct *work) -{ - struct kmod_dup_req *kmod_req; - - kmod_req = container_of(work, struct kmod_dup_req, complete_work); - - /* - * This will ensure that the kernel will let all the waiters get - * informed its time to check the return value. It's time to - * go home. - */ - complete_all(&kmod_req->first_req_done); - - /* - * Now that we have allowed prior request_module() calls to go on - * with life, let's schedule deleting this entry. We don't have - * to do it right away, but we *eventually* want to do it so to not - * let this linger forever as this is just a boot optimization for - * possible abuses of vmalloc() incurred by finit_module() thrashing. - */ - queue_delayed_work(system_dfl_wq, &kmod_req->delete_work, 60 * HZ); -} - bool kmod_dup_request_exists_wait(char *module_name, bool wait, int *dup_ret) { struct kmod_dup_req *kmod_req, *new_kmod_req; @@ -130,7 +106,6 @@ bool kmod_dup_request_exists_wait(char *module_name, bool wait, int *dup_ret) return false; strscpy(new_kmod_req->name, module_name); - INIT_WORK(&new_kmod_req->complete_work, kmod_dup_request_complete); INIT_DELAYED_WORK(&new_kmod_req->delete_work, kmod_dup_request_delete); init_completion(&new_kmod_req->first_req_done); @@ -230,17 +205,17 @@ void kmod_dup_request_announce(char *module_name, int ret) kmod_req->dup_ret = ret; + /* Inform all duplicate waiters to check the return value. */ + complete_all(&kmod_req->first_req_done); + /* - * If we complete() here we may allow duplicate threads - * to continue before the first one that submitted the - * request. We're in no rush also, given that each and - * every bounce back to userspace is slow we avoid that - * with a slight delay here. So queueue up the completion - * and let duplicates suffer, just wait a tad bit longer. - * There is no rush. But we also don't want to hold the - * caller up forever or introduce any boot delays. + * Now that we have allowed prior request_module() calls to go on + * with life, let's schedule deleting this entry. We don't have + * to do it right away, but we *eventually* want to do it so to not + * let this linger forever as this is just a boot optimization for + * possible abuses of vmalloc() incurred by finit_module() thrashing. */ - queue_work(system_dfl_wq, &kmod_req->complete_work); + queue_delayed_work(system_dfl_wq, &kmod_req->delete_work, 60 * HZ); out: mutex_unlock(&kmod_dup_mutex); -- 2.55.0