Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp709460pxb; Wed, 15 Sep 2021 11:14:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHdq+agDuMNmlwusk/xdGJChBzanPcAfTilF5peRNkXK8sIBjHo+8XyJwTFW7TQTSKOpXW X-Received: by 2002:a50:cb8b:: with SMTP id k11mr1447972edi.256.1631729640129; Wed, 15 Sep 2021 11:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631729640; cv=none; d=google.com; s=arc-20160816; b=BlyvBtO/0Kj6NPv6V/1gc3jrIaMJvO+ir+W0FYI0VGnjbrPOAYaYaKulUnhCTHYIqk m86pGKPgp+IdaaghYBmBfFGWVxHknLfNVbq7L+RQFdpsJzjeuJ5cAJv+I7dO+8yq1u7Z QseFjo3P2DxOz+vFkPF2urLpOk7vpr/FAEdgaFoZGR4fTjyrWut64kSORxUS/zWI2G9p pkj+Nvxwrb9U6r/j/BZQQIPwBS9VVqIjM6o/Tti5DoSeLjsw6FEQA6VnfZhDhEHOyBb4 uRI3EdegJG4lH8J+PruySVMahhYbOtlXGEC4aj11C5fia/+0luNnhmQftu8Xu/JYzIvP MQhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=qmtfPSicZt4+W2xOw2eszJcd4ZX5j/8yAZIvINEaqeI=; b=KS+vWeUWgWWqSFMmPuOcSWA1xQOndM6pWKnNFZE7OXME7RnFU3p/4/qVZmKwCN+Cl/ KWPsKdJ0I7nkOTt8ikd8MSogKwzFMIRzgenu4VgA8AA9dBgCac94/Q1l08FmGB1wT9rq 0aklE+KIy1Rm1wJghTNUzqvdqqpdO8zlmn6Gd78s+gPLb8w5xyaIFYKXn/HLt9BIjnDh z24qrjeNnNUTLzvP3xfDJ4/TjYtAsNd82qmgYXK4KDDFrsABDVV2MpPucy3HYQBjf2ou 8SyxcGVyRopQ4vOyKoKpPE5j9pYEbJFLl4p7Qz27MysL0PH81VaDoPu6g+z/cnCsl2+L UkRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=FQoBMAFP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r7si731897edo.477.2021.09.15.11.13.36; Wed, 15 Sep 2021 11:14:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=FQoBMAFP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbhIOSNi (ORCPT + 99 others); Wed, 15 Sep 2021 14:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbhIOSNi (ORCPT ); Wed, 15 Sep 2021 14:13:38 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FA78C061575 for ; Wed, 15 Sep 2021 11:12:19 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id a22so4602420iok.12 for ; Wed, 15 Sep 2021 11:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qmtfPSicZt4+W2xOw2eszJcd4ZX5j/8yAZIvINEaqeI=; b=FQoBMAFPRgxPefJNqhuYC1ycRXDOTjCVKeT+UiN4mRGYXHlPaPNCeAQAQr6ipL+ANA V8w2xDHKUi9HrakNPg2Bw9lDPKEAdwx5XED0kW8hur+XT7xD1YVIf5U/cWr8wQtjidvN wh/pLqEkXmljXk9SJLHQjp662qj+KXrUMFqlXfyJfi7dcNodAaE6Z/jm5B+xvLKL0zjF B2nj7day+w03GiIMfWwWXLeiBDHNQxXJPz2g4efYV3ILXzmcS0CkH+BK2NancUITIhGx HGz4JOg3rJ0LWP37/5c1YH5uwQO6PhXNDoaVT2QOWBJZHj5SgI9BtuJuyEa27w6A8to1 ngRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qmtfPSicZt4+W2xOw2eszJcd4ZX5j/8yAZIvINEaqeI=; b=QgJNMK1bWIX+vj4+G+EGVAgZujHMf7RueNz8krvP4fY8XZGkiX+25iOPvDMUhwMvc3 Eczx7ONch9w54zU0WamQ01kgsnFXkJ5AWHd9pjpjZc7TUOZqM0hizm7ncpVVXM1XkwLs WNFyof9a81BOzOnw1YwNMcVDBnQQeU6wVpbIslwgUmm8n8a21iRoHqwA4w2SYYlEeI+6 1H/A4yU+szvHOYEYyYjGxwg+rQQL48TGY2Q8EXxXtYugGjQCQjhLJ/nrqxkYANXhTHRF f5ILPrGYZFkcUDPrqQ3tW/W6zCeZnQtY1Z43x5QGJ72iXzFjpPSXB9XwXuCKwELsiOGw ovqg== X-Gm-Message-State: AOAM53356EKLmRdjMFWuS8+3zBFtu+0+E36jcpYOV60baGbta43tw2eG W5V6eziiyRDMDAWAL/M9i+HJ2A== X-Received: by 2002:a5d:9488:: with SMTP id v8mr1090849ioj.195.1631729538420; Wed, 15 Sep 2021 11:12:18 -0700 (PDT) Received: from [192.168.1.30] ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id r16sm348008ile.66.2021.09.15.11.12.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Sep 2021 11:12:17 -0700 (PDT) Subject: Re: [PATCH -next] io-wq: Remove duplicate code in io_workqueue_create() To: Hao Xu , Bixuan Cui , linux-kernel@vger.kernel.org, io-uring@vger.kernel.org Cc: asml.silence@gmail.com, Joseph Qi References: <20210911085847.34849-1-cuibixuan@huawei.com> <49d9bb13-a7b3-48b5-20ef-d3b72052f92b@linux.alibaba.com> From: Jens Axboe Message-ID: Date: Wed, 15 Sep 2021 12:12:12 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <49d9bb13-a7b3-48b5-20ef-d3b72052f92b@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/12/21 9:36 AM, Hao Xu wrote: > 在 2021/9/11 下午4:58, Bixuan Cui 写道: >> While task_work_add() in io_workqueue_create() is true, >> then duplicate code is executed: >> >> -> clear_bit_unlock(0, &worker->create_state); >> -> io_worker_release(worker); >> -> atomic_dec(&acct->nr_running); >> -> io_worker_ref_put(wq); >> -> return false; >> >> -> clear_bit_unlock(0, &worker->create_state); // back to io_workqueue_create() >> -> io_worker_release(worker); >> -> kfree(worker); >> >> The io_worker_release() and clear_bit_unlock() are executed twice. >> >> Fixes: 3146cba99aa2 ("io-wq: make worker creation resilient against signals") >> Signed-off-by: Bixuan Cui >> --- >> fs/io-wq.c | 9 ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/fs/io-wq.c b/fs/io-wq.c >> index 6c55362c1f99..95d0eaed7c00 100644 >> --- a/fs/io-wq.c >> +++ b/fs/io-wq.c >> @@ -329,8 +329,10 @@ static bool io_queue_worker_create(struct io_worker *worker, >> >> init_task_work(&worker->create_work, func); >> worker->create_index = acct->index; >> - if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL)) >> + if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL)) { >> + clear_bit_unlock(0, &worker->create_state); >> return true; >> + } >> clear_bit_unlock(0, &worker->create_state); >> fail_release: >> io_worker_release(worker); >> @@ -723,11 +725,8 @@ static void io_workqueue_create(struct work_struct *work) >> struct io_worker *worker = container_of(work, struct io_worker, work); >> struct io_wqe_acct *acct = io_wqe_get_acct(worker); >> >> - if (!io_queue_worker_create(worker, acct, create_worker_cont)) { >> - clear_bit_unlock(0, &worker->create_state); >> - io_worker_release(worker); >> + if (!io_queue_worker_create(worker, acct, create_worker_cont)) >> kfree(worker); >> - } >> } >> >> static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index) >> > AFAIK, this looks reasonable for me. I took that as a reviewed-by, let me know if that isn't correct. -- Jens Axboe