Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C399C433F5 for ; Sun, 21 Nov 2021 17:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238669AbhKURxY (ORCPT ); Sun, 21 Nov 2021 12:53:24 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:47872 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238631AbhKURxO (ORCPT ); Sun, 21 Nov 2021 12:53:14 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1ALHPpo6007323; Sun, 21 Nov 2021 17:49:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=W0Rytdc0l5QWqNp5tZ8p7WidQP/k88bStWgcvhD0LPM=; b=SB/rBH9Oe7DqnxGSN4RrViwU3e058JCPmgPr6iuwteo09m3y8tRRrHxsNqO3OAcFC/6C 8SmxSoKg6d87pvGmUlDLG9+bBzbMGgPoscVSDqHh9ruR2k2Q8KK4tlyFtY3B5y+lZKso 3L5c/Qq9A+mKovCG8dOlTujqu3328D1xOJ5kmbLnVcYZnopJqm5E34UciZDJVgvkv8E/ 4ftUoImAIyt9ojbK+jKF82ZWJGuoDo2LYQH/ySa5/qHdvstq/PiA8Ao5qSuj/DNzcCVk Ocap4yIIPpCuqd1+cQfxdKCf4fOd6fdXcKDmczrtazTn8m8NwtcBTQwecW5QzR9cLgou kA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3cesjtmd5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Nov 2021 17:49:51 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1ALHkUY3015043; Sun, 21 Nov 2021 17:49:50 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by userp3030.oracle.com with ESMTP id 3cep4vp60k-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Nov 2021 17:49:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NWz/qgtxtkbd+LEvE6DDyy89SGYqxqr+ile/XVWL8jANZHI/X7TH2XHWt3UpTiZTIvv3KVOvTOKv7Hn0LKmIu3AiFQRz9N+sr/ls3bJBBEInUSjAhUNDvW9WLSK2FQoUCNOecs2bANos5mfjz76FOKOowUsRq51asV9qOb6C+pM0cycoH1T7rXfdfbue/69DyXmCV+JelfEpW6mG3UQJ0zOCNWD7EosCv8rFbX5S0PAdaw6ACWLsmfWV6Qzufil7LYDMFZRlx/06duCc94DO10lC1Is3vl2HF5ZWww8CcOzBkdqYKf/snABUEQzKYzQ6tMUiIUkcElTCdfKh9oSUdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W0Rytdc0l5QWqNp5tZ8p7WidQP/k88bStWgcvhD0LPM=; b=M0kAPHs/XLd3Fy/8txnJC18Gv7k0q16wvx5oka282lraIy++KA2/v6SNTrVX5ArhnjJwYg/2FGfuAFuGzgCl22IsMddCTWDWD2v6zYIWl5UFwiiGELOsApXu/ygJYbWyzfIDkxl2Ll8HAJwLdllLBYTyvEvkGyZN8HM60ZdlZs87rh0HA4ltO2DEJakThktKU3u+dbS6UNq4jVeC21RsY1bGmMpz70+iXbLyYzoWCjAyWRVAmsyvtb7jHDFEwemWgpU4VS6Vng2MOBdNMhagi5XvuO8IUNYGmqPKjeHFICQjLr2WcTW4BZLQuB+pHijjA6B2PMYCLXY2EiE2tTxBwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W0Rytdc0l5QWqNp5tZ8p7WidQP/k88bStWgcvhD0LPM=; b=seZuQF64g4LX8cTyyo3JSSrJVXM0YoeD71bE1DZAAxZhpT3dRc1xP9u9NeacHs+Rs5yM0TtFiEDO35lwVtI9sfBVAZhSGDzUl0KJq7DT2cIj/WkOkB6EWyV7UtXogQEjwjkNVvYvutUomFcjYONO2BuI6jtqBRtfYvR66c9TEX0= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DS7PR10MB5055.namprd10.prod.outlook.com (2603:10b6:5:3a9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Sun, 21 Nov 2021 17:49:49 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::601a:d0f6:b9db:f041%11]) with mapi id 15.20.4713.024; Sun, 21 Nov 2021 17:49:49 +0000 From: Mike Christie To: geert@linux-m68k.org, vverma@digitalocean.com, hdanton@sina.com, hch@infradead.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org, christian.brauner@ubuntu.com, axboe@kernel.dk, linux-kernel@vger.kernel.org Cc: Mike Christie , Christoph Hellwig Subject: [PATCH V5 07/10] io_uring: switch to kernel_worker Date: Sun, 21 Nov 2021 11:49:27 -0600 Message-Id: <20211121174930.6690-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211121174930.6690-1-michael.christie@oracle.com> References: <20211121174930.6690-1-michael.christie@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: CH0PR03CA0217.namprd03.prod.outlook.com (2603:10b6:610:e7::12) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0217.namprd03.prod.outlook.com (2603:10b6:610:e7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Sun, 21 Nov 2021 17:49:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ef1ab5e-3479-4bfc-242a-08d9ad175044 X-MS-TrafficTypeDiagnostic: DS7PR10MB5055: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:107; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CrI8ZVRKFVAI93odc6Egav/62n69lRpt5jrJlu3e6xZdXmf0PRCPJfxBz2dnhgV68Hbss6cUNKnBgILIc8GY6edEiIa+TewI57oVjPqKbOEHBMvhYTpIw/8UqqFPGKpFIV0u8DIKQZp6NZxCiQ/ogn6Lbt2WjIuqrKVVaPXCvkoGt5ii4btV8TQf2gRV4YsfxyQ41YyKw5cx4OvvBKYnpXNRUutnj6mZ2OBup8bjddLASLdkJsSOcSbYt+ksF6HTcyp61yzM/Wu9E6b08MO1PGUeqQv6VQ2/3lQQX1oM3DVLy32yazmGcnxwhE/+tuHzUiwRWP8+AX2u5IjHLoQcI+ShvtZ17alF8/5czyiv0nUQw90+MO/YyN+dONJ7YPdrTwGK4V65/ZyFpDRd+y/gjMemx86qvDxdTNZLGCIZ+K1LjfVgK9uTBaTMz9jEPaE6fKPnE7gSOllDCchRfvB+TURFBUu/dmICZcfgZA3cRqzTcSd189j75JzslRxbr0njA/+pXr5eAyNlPWrwQYJWl3Jizb+ixaKeo+IxHluzRkwO1pTDq+0sPspxmFSeyT5EAk4o22w4oL2ryY3sVa1oiA70aI8fAC1z64jzUqPrNAfusyeQrJCE3211b/6i1kfW0NdPeqfjpKfoYQzGTtp8SAN+q3oyeclGk9uBK/MjUXyvORaUvGlPJdLpDie1GW37h1cBHjDEZDvfP4ncPqr9Sicy0tSl4NMPQZtDjepqX9k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(8676002)(66476007)(52116002)(38350700002)(5660300002)(8936002)(1076003)(2616005)(6512007)(6666004)(6506007)(7416002)(66556008)(4326008)(2906002)(316002)(86362001)(921005)(54906003)(508600001)(38100700002)(6486002)(83380400001)(26005)(36756003)(66946007)(186003)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ql0aMF6qpFeFR3Nt4E9yjIzPrL6Z6WBD7djEyPlinIrErlgGzmkKuuLPdFDK?= =?us-ascii?Q?sMYTqsDXX0DHDkeUkk+4MiBcpBWoNF5qCZgYo1o7pntMW+2+3jRoRcAO9R1G?= =?us-ascii?Q?tepFBBhy56Ra+zvT1TNd+icOGF6Up2w6hhz9iJYl0OM8tV+5fdcnKspEnMdm?= =?us-asc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+Q9fSym11Q1cWjslm0zjc8P?= =?us-ascii?Q?XckyjqXQicqaYuUqWnhND3V/oxFf0wJ8mE+AbkVRmrFRCsGNnJEhN1m0r5/6?= =?us-ascii?Q?ypx+asFz57c5MG6i3Sk3YKjmB6es9wyPF7vVruGFfqxKBaCA0RW1qsD7qGI5?= =?us-ascii?Q?u4P9MBLL5x3beXxhTeAlqubpGweAgr8zcoWX4nPTlX7kh+fuGuzL8KMa5N9M?= =?us-ascii?Q?/cJ0qj5MLkvK2G0Ns5LTQw5CHsqZXLgcIsZV+YMcle25GIKlz6nqxXT7ISmd?= =?us-ascii?Q?oN9QQlXM5060xDOQFGXcHwbHSQQiks3nzhHj7s7OcoO4Ut6cH9EDjLFDpniL?= =?us-ascii?Q?uZpjdE8b9m4nBvxSBtS6WrRPF5EeEtpaMq915QOAhvs8YQTz/DCGl/PWFhCK?= =?us-ascii?Q?g8+zxF4CO6eZW/SVgj7QqEMp01qEs2zjv8AotpS6HySFwWrj2rDvT/JKQuf+?= =?us-ascii?Q?e0NES7mtdRGaHVAx86eMmEzBlQe5uUiWsnHajbbhyV6neVJCIRkvk++lKZst?= =?us-ascii?Q?l448NHZlEkBr//r+aV9lLhDWQXtAoRRpv0egQBjt35RBIUjdYtQBKfmb6K9U?= =?us-ascii?Q?pgaL+lkbgjk4OjzQdAK41rxGmEqzFG12uuCvgclD5RhhDtiwjDO8w/rm5PEC?= =?us-ascii?Q?UoKTxA=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ef1ab5e-3479-4bfc-242a-08d9ad175044 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2021 17:49:49.3471 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EtwmRTG+ARZE688MZlHMzhPvYjtuHedderyjSzqRPVABjYEMkh0IpYSP1pzpx38Ee/yA4Br8JAb9AOyuMo04jydnp3F/PYr5xPgOUL83fS8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5055 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10175 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111210110 X-Proofpoint-GUID: G_kl9wNk__CWexunvymJeSEj5fgUr2Lm X-Proofpoint-ORIG-GUID: G_kl9wNk__CWexunvymJeSEj5fgUr2Lm Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert io_uring and io-wq to use kernel_worker. Signed-off-by: Mike Christie Reviewed-by: Christian Brauner Reviewed-by: Jens Axboe Reviewed-by: Christoph Hellwig --- fs/io-wq.c | 15 ++++++++------- fs/io_uring.c | 11 +++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/io-wq.c b/fs/io-wq.c index 88202de519f6..b39cf045d6ce 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -70,6 +70,9 @@ struct io_worker { #define IO_WQ_NR_HASH_BUCKETS (1u << IO_WQ_HASH_ORDER) +#define IO_WQ_CLONE_FLAGS (CLONE_FS | CLONE_FILES | CLONE_SIGHAND | \ + CLONE_THREAD | CLONE_IO) + struct io_wqe_acct { unsigned nr_workers; unsigned max_workers; @@ -600,13 +603,9 @@ static int io_wqe_worker(void *data) struct io_wqe *wqe = worker->wqe; struct io_wq *wq = wqe->wq; bool last_timeout = false; - char buf[TASK_COMM_LEN]; worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING); - snprintf(buf, sizeof(buf), "iou-wrk-%d", wq->task->pid); - set_task_comm(current, buf); - audit_alloc_kernel(current); while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) { @@ -704,7 +703,7 @@ static void io_init_new_worker(struct io_wqe *wqe, struct io_worker *worker, list_add_tail_rcu(&worker->all_list, &wqe->all_list); worker->flags |= IO_WORKER_F_FREE; raw_spin_unlock(&wqe->lock); - wake_up_new_task(tsk); + kernel_worker_start(tsk, "iou-wrk-%d", wqe->wq->task->pid); } static bool io_wq_work_match_all(struct io_wq_work *work, void *data) @@ -734,7 +733,8 @@ static void create_worker_cont(struct callback_head *cb) worker = container_of(cb, struct io_worker, create_work); clear_bit_unlock(0, &worker->create_state); wqe = worker->wqe; - tsk = create_io_thread(io_wqe_worker, worker, wqe->node); + tsk = kernel_worker(io_wqe_worker, worker, wqe->node, + IO_WQ_CLONE_FLAGS, KERN_WORKER_IO); if (!IS_ERR(tsk)) { io_init_new_worker(wqe, worker, tsk); io_worker_release(worker); @@ -801,7 +801,8 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index) if (index == IO_WQ_ACCT_BOUND) worker->flags |= IO_WORKER_F_BOUND; - tsk = create_io_thread(io_wqe_worker, worker, wqe->node); + tsk = kernel_worker(io_wqe_worker, worker, wqe->node, IO_WQ_CLONE_FLAGS, + KERN_WORKER_IO); if (!IS_ERR(tsk)) { io_init_new_worker(wqe, worker, tsk); } else if (!io_should_retry_thread(PTR_ERR(tsk))) { diff --git a/fs/io_uring.c b/fs/io_uring.c index b07196b4511c..d01eef85cc03 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7431,12 +7431,8 @@ static int io_sq_thread(void *data) struct io_sq_data *sqd = data; struct io_ring_ctx *ctx; unsigned long timeout = 0; - char buf[TASK_COMM_LEN]; DEFINE_WAIT(wait); - snprintf(buf, sizeof(buf), "iou-sqp-%d", sqd->task_pid); - set_task_comm(current, buf); - if (sqd->sq_cpu != -1) set_cpus_allowed_ptr(current, cpumask_of(sqd->sq_cpu)); else @@ -8665,6 +8661,8 @@ static __cold int io_sq_offload_create(struct io_ring_ctx *ctx, fdput(f); } if (ctx->flags & IORING_SETUP_SQPOLL) { + unsigned long flags = CLONE_FS | CLONE_FILES | CLONE_SIGHAND | + CLONE_THREAD | CLONE_IO; struct task_struct *tsk; struct io_sq_data *sqd; bool attached; @@ -8710,7 +8708,8 @@ static __cold int io_sq_offload_create(struct io_ring_ctx *ctx, sqd->task_pid = current->pid; sqd->task_tgid = current->tgid; - tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE); + tsk = kernel_worker(io_sq_thread, sqd, NUMA_NO_NODE, + flags, KERN_WORKER_IO); if (IS_ERR(tsk)) { ret = PTR_ERR(tsk); goto err_sqpoll; @@ -8718,7 +8717,7 @@ static __cold int io_sq_offload_create(struct io_ring_ctx *ctx, sqd->thread = tsk; ret = io_uring_alloc_task_context(tsk, ctx); - wake_up_new_task(tsk); + kernel_worker_start(tsk, "iou-sqp-%d", sqd->task_pid); if (ret) goto err; } else if (p->flags & IORING_SETUP_SQ_AFF) { -- 2.25.1