Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp591967ybg; Sat, 26 Oct 2019 03:58:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhLcT0GN/R+7GsWISwU5d8z9pcmVqR1z9iUkTJV8LJE/m5I5QFvo5TdKvLAYwKZcuJfjSo X-Received: by 2002:a17:906:e82:: with SMTP id p2mr7595313ejf.237.1572087535158; Sat, 26 Oct 2019 03:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572087535; cv=none; d=google.com; s=arc-20160816; b=Y9G58ufq9SaGbiMxttjyVNu0N5xbpAsOK8h+BuO1U3VIOIbhsoUMGBhSHTfzKHP/V0 wPvF+kH5ZrsUv8XOPLUvJewPqSg6ROWrLNyCZg1Vf0noPKpa1T7Tb3AHl5exkZDZHvQO Ly35hE7nNHi2JbzK4oOiEEV/13rXKaj7fCUD2AfVF0/qe5zyzD7PF9AfWG7RoafNxEFw ggXgdI0bzWefykhkuqkhm/8yQFWhgdq+XSLTPA02xuT3+iXqi/G9fGjqZQgp9ICfkcYb sgvWjavWNMbeZ3Q0CRP4nT2VQXinO7DZ+WQzt4iuQ4GeysYttzqfEfHsA+3kGGB+PFTh IJPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=Hq4CAbHynA5ayS3gTLK82owtjcj/ExTubwlxfFz/EO0=; b=L62XtMLTBOvBnKmfVCGeXIYA7zOkHKs2w4ycoDDVP+dHCrCbQxkfTrDhAip9SV81gp 3ZoyZn7qJm7PLH3yZwGdWWsX6p+ate8eEoNewgGzMsh5qokFS/W8fl6GPsi0H746mJ8e oy8YbYQy51RUEMZPawbN2+FU+BTLll3IPcUHxtThIs6NHSl5XDToJ7xOVvBn8U7ZQSja GwLieOIyWg/hwku0ZjSspdRGwQ7r3puADF0zIou5ungJp5kl7AQoky4U1t03wLpe/gcA Epsw4OX+6yUknkaYcA/77LtA6JeXGj84aguEWNdcK6rv6cqslCvpJGroLOFBIc0CkD8N bVkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7si3512746edb.401.2019.10.26.03.58.29; Sat, 26 Oct 2019 03:58:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726175AbfJZK5W (ORCPT + 99 others); Sat, 26 Oct 2019 06:57:22 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4771 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726120AbfJZK5W (ORCPT ); Sat, 26 Oct 2019 06:57:22 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1656D33C7A973CFD2ECF; Sat, 26 Oct 2019 18:57:20 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Sat, 26 Oct 2019 18:57:11 +0800 Subject: [PATCH v2] async: Using current_work() to implement current_is_async() From: Yunfeng Ye To: Bart Van Assche , Alexander Duyck , "gregkh@linuxfoundation.org" , , David Sterba , "tglx@linutronix.de" , CC: "linux-kernel@vger.kernel.org" , "hushiyuan@huawei.com" , "linfeilong@huawei.com" References: <0147097c-0ce2-5944-932a-8fd53eed4ff6@huawei.com> Message-ID: Date: Sat, 26 Oct 2019 18:56:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <0147097c-0ce2-5944-932a-8fd53eed4ff6@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org current_is_async() can be implemented using current_work(), it's better not to be aware of the workqueue's internal information. Signed-off-by: Yunfeng Ye Reviewed-by: Bart Van Assche --- v1 -> v2: - add "Reviewed-by" kernel/async.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/async.c b/kernel/async.c index 1de270d..a849f98 100644 --- a/kernel/async.c +++ b/kernel/async.c @@ -53,8 +53,6 @@ asynchronous and synchronous parts of the kernel. #include #include -#include "workqueue_internal.h" - static async_cookie_t next_cookie = 1; #define MAX_WORK 32768 @@ -327,8 +325,8 @@ EXPORT_SYMBOL_GPL(async_synchronize_cookie); */ bool current_is_async(void) { - struct worker *worker = current_wq_worker(); + struct work_struct *work = current_work(); - return worker && worker->current_func == async_run_entry_fn; + return work && work->func == async_run_entry_fn; } EXPORT_SYMBOL_GPL(current_is_async); -- 2.7.4