From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 92D613FCB39 for ; Mon, 20 Jul 2026 12:16:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784549810; cv=none; b=TrqU2Ss8g1IRQuCtDdSCctKiRP3WcWqc/z/dd3FtmmOBHUokKzw670TDNeapAYGtfXa0UZS57ZX3DyXZc0lsIBvY7/60sStA1UQdc5cqqFnFPYlT96D/yFFM065tRtYAzVZb0B3HVQZD2XL1d1T663yQmUcQo1m5JkWmmHbNQMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784549810; c=relaxed/simple; bh=I27ZSoF/OSRvlq21arNznTNvwbY86IMVngIZDjHTjxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mNuh7PpvDyqSaqzkJipn7dJ4NmzWxR6NJplasGvCGaz6dFGaaB2tuseBRouySR72zUbdRHEzi2sK7EqcuCstU5nbpkA3DPPyNOA1ThRf2Z8pwrcto7P22URLAiqIK6bRtI2Bid4FYTHVxXSSi+pxHl3ANuEhs5fEsXP3kPaUp14= 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=MAtnohK7; arc=none smtp.client-ip=209.85.128.41 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="MAtnohK7" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-49557167508so15467305e9.1 for ; Mon, 20 Jul 2026 05:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1784549802; x=1785154602; darn=vger.kernel.org; h=content-transfer-encoding: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=ZWDVnnTRs9ulUtHM6zxZ6aVf5x++4G1ngbdh0GBn31o=; b=MAtnohK7vAtv0l7JxtVdU/rQBMALWosUrSzCEQJ6UwwVauQ0iGeT1hOFw+gjEpK2Jh b+iwC6xa87N8auXSXbP1DEBJ89fbWRr+g8e31RFaBF6vthhIT/o3tvU3siTsdMKqkexs eV1mkauK4+d0o8pgqiX0dHk6dY8gNOBJQbsDlEnbtRYaqBIHKQUpIar6/fT8uJQclvJr 19b0PZy77XQJVQNVv6SJPOyLHfL4IWOdSPuvSlomWalLx/7kdCvNqT0A4aRhwTGW/cVF oTgnMXx+8CV1bwKPFEvK97nkTer8dFczAgZXWwg9oPswNheWBHtp1zQAXYU2xkW3jqxn C33A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784549802; x=1785154602; h=content-transfer-encoding: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=ZWDVnnTRs9ulUtHM6zxZ6aVf5x++4G1ngbdh0GBn31o=; b=N3AXG8w/wyC2viVqfNhus8RVyndn9D7cv1b7UOOAz4DRDTo6soGhCZEr+LSoZNsqey v483R93lNGBFsHMW2jG0k2u14HIjVa6cKVbDc14x2Ml+t8wbxauWhZrBrBrA5orO91l7 knYvInDUcaohjcsCy7nbBuz+me6BtmHnn4484Q3ImOF/9oUGCWHVp4E2PA7JYuiQywxU /SJzYqWQ13aPKcL42KWKixVGubNoH/+jffgB20qese9N86WGGUi3LaO/ORzkmTpEkgqe Mn8rfHi1Q3Ifm6lKMMAFgL/K78U4irLFXMojWdPZ5mtGWFi73BH0ggynprdMCk/e4Qd/ e3lA== X-Forwarded-Encrypted: i=1; AHgh+RrN8YqTduBKKRSEgeBbsUWyVxXUicITcZ6PL9sTddkm0begD3IvP2NbnNJSp0FU6bRi/KFtgx8WIKiearA=@vger.kernel.org X-Gm-Message-State: AOJu0YyQHXvZHpTKt5TcUVfwxWLo2fseuEa+AjX/qLyfu8li5bKFVB87 zmzqgZJqPizdnLWKJURNsDhGt7fZLM9moKuhnd+HfCavGnZctTiyXrF+8CDHNbHkFZs= X-Gm-Gg: AfdE7ckdJ0GsxcjzT9CL8k2hnYWXcbQcNNp1KtvcXmpCyFdu4VMWRXLg3iTxU5eF5sT jgxFbSzt65JsbEdjq9vK+fTfIti8Ccb5YtR45QGln/uYAcmWIiJBU1s3KYbj4uNl0dq/yZICGYX TL+PMo85JbwfmBvr4uAgnfxnzwKAp3zRxu+z7I0Po5mmUNK53xIfeoYrCrPnLkAW5q4hW3J/hQs gFqSccLCkh6Uvjr+qMQBhb0/ELPyoBo1ZBTc2znRAb1qYUHDf4g51E4T7R/bJgqGUskF0gGZmWa X3oiSKsbqAtN0Aths01s/gke+8SbIXKbfm6Z9PzvBs0bXhZYVdQCCb/EAZNqPB9HDlBCbGRfQ+i 3eVttH+jjn3vD2uhvYCBe6PG2CMoD+vtTh6/7lg4ggnsHMaXHc96uL7WzoJhGT73mUKGfIzQfUA == X-Received: by 2002:a05:600c:b85:b0:495:5365:c0d1 with SMTP id 5b1f17b1804b1-49553d85ea0mr100454075e9.14.1784549802399; Mon, 20 Jul 2026 05:16:42 -0700 (PDT) Received: from zovi.suse.cz ([2001:af0:8000:1409:193:86:92:181]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed1911sm31424338f8f.22.2026.07.20.05.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 05:16:42 -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 2/5] module/dups: Inform duplicate requests about the result directly Date: Mon, 20 Jul 2026 14:15:27 +0200 Message-ID: <20260720121621.750661-3-petr.pavlu@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260720121621.750661-1-petr.pavlu@suse.com> References: <20260720121621.750661-1-petr.pavlu@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 50 +++++++++++--------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/kernel/module/dups.c b/kernel/module/dups.c index e1828e865edd..f0bdd7560d7e 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; }; @@ -105,29 +104,6 @@ static void kmod_dup_request_delete(struct work_struct *work) put_kmod_req(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; @@ -143,7 +119,6 @@ bool kmod_dup_request_exists_wait(char *module_name, bool wait, int *dup_ret) refcount_set(&new_kmod_req->refcount, 1); memcpy(new_kmod_req->name, module_name, strlen(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); @@ -246,23 +221,22 @@ void kmod_dup_request_announce(char *module_name, int ret) * that is owned by the current task. */ kmod_req = kmod_dup_request_lookup(module_name); + mutex_unlock(&kmod_dup_mutex); + if (!kmod_req) - goto out; + return; kmod_req->dup_ret = ret; + /* Inform all the 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); - -out: - mutex_unlock(&kmod_dup_mutex); + queue_delayed_work(system_dfl_wq, &kmod_req->delete_work, 60 * HZ); } -- 2.54.0