From patchwork Tue Oct 15 23:30:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Whitfield X-Patchwork-Id: 1997735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSr205rRzz1xth for ; Wed, 16 Oct 2024 10:30:48 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1t0qzx-000103-6T; Tue, 15 Oct 2024 23:30:41 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1t0qzu-0000yV-WA for kernel-team@lists.ubuntu.com; Tue, 15 Oct 2024 23:30:39 +0000 Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 6CC373F6B0 for ; Tue, 15 Oct 2024 23:30:38 +0000 (UTC) Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-288c88ba0f7so1608114fac.0 for ; Tue, 15 Oct 2024 16:30:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729035037; x=1729639837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NB1++NLsveL5Eph/ag5cjHQB+nMPZO7lBHtn5n9zDz8=; b=hGUws7hZXsjS138vY2ODfo5Ol/aiD2aj7XUKUDBXAGd8FMWSlm5Y0MjHRiJT2qzlql +DCclN9cafH0vLgZP/C2dkj16wmLKZWRLdNxTa5ryNehJnOa+JNLO70e1JcxxCXEVFIG Ff7FpNdqg4lOr/cYLNcDogQBCB8BaFctjMvxSKHrkMktdruze2USgDW8MSEVnQ3yaW6D pRhFjfhnsZZAa1X5ntxE/VuZQucKVbfiXe3vzTYf1bgptda8fsUXV9T5t3afkSiGjKmr 2UcRo4VJ+BrAqKA+AvAISIjx+aTAW+5Apda8htgdXH+8SsuFBkvcI5lW44GLo8Lu+mRG IUBA== X-Gm-Message-State: AOJu0YxJZpWM3aGVRgf1aCewhqXstBOWIlfk0DnkqWIF+nJUbg9cf7Ms c9533NXO2+VnNC5w7ZH1+vuIiOquHQXzl9qTvrruw+Z5xQ8lnWV2hBVwEtladAgqVfDAokkxyuv TxSxPs7rvvI/xIzKsP8Qk+K6sdBLlePTFZ19wSgNYOQp41ni+fce+kztpQD79vI1s2YD346vj/Y H1UpsOTBeSwA== X-Received: by 2002:a05:6870:659f:b0:27b:2e84:fedc with SMTP id 586e51a60fabf-2886de48619mr12628231fac.21.1729035037042; Tue, 15 Oct 2024 16:30:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGbFpeomIee1XKzRW/xTo6bQeenvnKTxk8gZFvT6VuTRH5XLJ98hdDp33drKHV/6It6QUN7w== X-Received: by 2002:a05:6870:659f:b0:27b:2e84:fedc with SMTP id 586e51a60fabf-2886de48619mr12628217fac.21.1729035036477; Tue, 15 Oct 2024 16:30:36 -0700 (PDT) Received: from localhost (172-10-233-79.lightspeed.sntcca.sbcglobal.net. [172.10.233.79]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-288dac0d58bsm588941fac.23.2024.10.15.16.30.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 16:30:36 -0700 (PDT) From: Ian Whitfield To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH v2 3/5] async: Split async_schedule_node_domain() Date: Tue, 15 Oct 2024 16:30:21 -0700 Message-ID: <20241015233023.75625-4-ian.whitfield@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241015233023.75625-1-ian.whitfield@canonical.com> References: <20241015233023.75625-1-ian.whitfield@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "Rafael J. Wysocki" In preparation for subsequent changes, split async_schedule_node_domain() in two pieces so as to allow the bottom part of it to be called from a somewhat different code path. No functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Stanislaw Gruszka Tested-by: Youngmin Nam Reviewed-by: Ulf Hansson (cherry picked from commit 6aa09a5bccd8e224d917afdb4c278fc66aacde4d) CVE-2023-52498 Signed-off-by: Ian Whitfield --- kernel/async.c | 56 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/kernel/async.c b/kernel/async.c index 1746cd65e271..dfa4ed15cc42 100644 --- a/kernel/async.c +++ b/kernel/async.c @@ -145,6 +145,39 @@ static void async_run_entry_fn(struct work_struct *work) wake_up(&async_done); } +static async_cookie_t __async_schedule_node_domain(async_func_t func, + void *data, int node, + struct async_domain *domain, + struct async_entry *entry) +{ + async_cookie_t newcookie; + unsigned long flags; + + INIT_LIST_HEAD(&entry->domain_list); + INIT_LIST_HEAD(&entry->global_list); + INIT_WORK(&entry->work, async_run_entry_fn); + entry->func = func; + entry->data = data; + entry->domain = domain; + + spin_lock_irqsave(&async_lock, flags); + + /* allocate cookie and queue */ + newcookie = entry->cookie = next_cookie++; + + list_add_tail(&entry->domain_list, &domain->pending); + if (domain->registered) + list_add_tail(&entry->global_list, &async_global_pending); + + atomic_inc(&entry_count); + spin_unlock_irqrestore(&async_lock, flags); + + /* schedule for execution */ + queue_work_node(node, system_unbound_wq, &entry->work); + + return newcookie; +} + /** * async_schedule_node_domain - NUMA specific version of async_schedule_domain * @func: function to execute asynchronously @@ -186,29 +219,8 @@ async_cookie_t async_schedule_node_domain(async_func_t func, void *data, func(data, newcookie); return newcookie; } - INIT_LIST_HEAD(&entry->domain_list); - INIT_LIST_HEAD(&entry->global_list); - INIT_WORK(&entry->work, async_run_entry_fn); - entry->func = func; - entry->data = data; - entry->domain = domain; - - spin_lock_irqsave(&async_lock, flags); - /* allocate cookie and queue */ - newcookie = entry->cookie = next_cookie++; - - list_add_tail(&entry->domain_list, &domain->pending); - if (domain->registered) - list_add_tail(&entry->global_list, &async_global_pending); - - atomic_inc(&entry_count); - spin_unlock_irqrestore(&async_lock, flags); - - /* schedule for execution */ - queue_work_node(node, system_unbound_wq, &entry->work); - - return newcookie; + return __async_schedule_node_domain(func, data, node, domain, entry); } EXPORT_SYMBOL_GPL(async_schedule_node_domain);