From patchwork Tue Feb 7 10:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JaeJoon Jung X-Patchwork-Id: 53815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2763232wrn; Tue, 7 Feb 2023 02:15:45 -0800 (PST) X-Google-Smtp-Source: AK7set9NwctnU+UFVfr40hDO/pXX9l1Zl8KcxpgxU2+TzhSGiFT/m6UkGO0eS2x+5kHJ9/OOsHwB X-Received: by 2002:a17:906:3159:b0:88f:a23e:6f0d with SMTP id e25-20020a170906315900b0088fa23e6f0dmr2859684eje.37.1675764944989; Tue, 07 Feb 2023 02:15:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675764944; cv=none; d=google.com; s=arc-20160816; b=cN9rXD06gTbW56srLmuPuUxSXt9iQPs9aZY8T4E04plqN6NQvNGtPrx24csIV79DyV EhaNRGNspQa+fGcrNTUF0ptkh9q658VSV6cmxKNXnc2pnOLBygm3xnDbF21pQtCKjrVZ 7GCtuoXh5g/uchP5rFIK80Cz3v3Eloqy4EzdmAVw/D6+1r79xRMJx+lWfoRFCDqOOvHq z5TFC99+cjxOA5NkToU01Kf6MCXJ+GHzzw7Ly1L5t66T6j/jgKtcUgqlY2ARnKMgV7TO MyZ+zQxR4mMO7lrsU2LzOr5zZ2OuSim2+ubCd3RT98epLQDzltd9h/4kMCEbg/Faalvu vBAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=+yniRi0vL0jtulkcpPba003O3or0uEtpgoqwm7lDS7g=; b=s+DcZj6IsJbs8gF6zCGqtHa92pEw/Opzi5zVOE+QMuJXkVeT57TgS30jQfcR8mMLlz DH9sxfYHP+jjpsnBdf+YRk0h0ejl8CSCCRdQJk963wDe9mDVZPygMP9brjTjyZ8ThRi4 oQ9CTwF7OLey4Fifl/nV1XJFKODvKkaYlZIBiwR+QoXq9xFVO4O5MpdAMN1/Cgmd5IGD sa8pNN35/cLhMoUTCnNdIFiPr064fM5JVuPnWX4NkkCo2veJnfh4gwvYKCeMTJ8bkeIf SNspsXzwnD6UotuafgecWma97xAs3XEF94DIX/gBpl7VIRxoSF8YatA7PSKkciBCGtqL zRRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z7Fx1JI4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay5-20020a170907900500b007a1d4f0e7fcsi13520752ejc.655.2023.02.07.02.15.20; Tue, 07 Feb 2023 02:15:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Z7Fx1JI4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230460AbjBGKMJ (ORCPT + 99 others); Tue, 7 Feb 2023 05:12:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231559AbjBGKLx (ORCPT ); Tue, 7 Feb 2023 05:11:53 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 683D07689 for ; Tue, 7 Feb 2023 02:11:51 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id gr7so41820518ejb.5 for ; Tue, 07 Feb 2023 02:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=+yniRi0vL0jtulkcpPba003O3or0uEtpgoqwm7lDS7g=; b=Z7Fx1JI4k/6dH5JjLN2sre7oFeJzzXEs3o2qTuC8/T2riLMscduZbzntrzBz+x3jsT 8LfY2VSGoo19MhSy0wFkuLyx1M0L59cEDWN3wXE6bro0nb9BlJgYiRMPDdKMe207xuqZ WU+dnD0u9s6lNG6avsIzjMlIBK9z3yvy1F/3SHdN/5DWE5x3QftrtetAQolMfz1WsqUM VwkhCDpVqkduIlx1G+HmC/tEXnl2vQ+/4BnIz6EFIE67qFg3XjkPXhqHJla5n5xurjl4 8CH2iX9mVEDDPvQDyXrlE+bVKaEstbUJBHj/jydKrByvTLnN7dvEC+X5nQB8ZvDg1lmv 9R9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+yniRi0vL0jtulkcpPba003O3or0uEtpgoqwm7lDS7g=; b=xPlNQSxTetsCYjSpNgr2rOqifE2125LaHJLDgCNKenxG+mB4GA+BoiJqxN+Eqfll3n PbOP0i6tuWQoc6wcJiJvMXmiTfd1N3VZW3fyaP4WvraEMwNW4MQy51wJgCRHIDOvWpFz Ag/MKWYStqQAXRJ0/S+ofnRrP60w/rNI/N3wP9C8ktafxD/xdw9d3+sSXndd0L1LXOHs HTdZpWYwzOPHPqtp5QgudAdBn2jmGEiBKBe/gtuprTLLhRxnmthKViQAG1tSmiFopTQx U5D4+0UlZBB2GdEOgRF1vQlaYm3xMK3vW0GYMfphWMMuMIg+XJaxMSc6XKKslSvyne5F fVNw== X-Gm-Message-State: AO0yUKWjHq2FYoyjbK8leIv5CxYF9Dxv1yPH4Z443IZIkmanUCVgqtaR zE04xPfawxyZlV7VM4jolKSDUR85zFPHgXDWjl8= X-Received: by 2002:a17:906:3e88:b0:880:b580:d93 with SMTP id a8-20020a1709063e8800b00880b5800d93mr713023ejj.276.1675764709933; Tue, 07 Feb 2023 02:11:49 -0800 (PST) MIME-Version: 1.0 From: JaeJoon Jung Date: Tue, 7 Feb 2023 19:11:38 +0900 Message-ID: Subject: [kernel/workqueue.c] Unnecessary WORK_OFFQ_POOL_NONE in the worker_pool_assign_id(), idr_alloc(). To: Tejun Heo Cc: David Woodhouse , "Theodore Ts'o" , linux-kernel@vger.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757166903121967142?= X-GMAIL-MSGID: =?utf-8?q?1757166903121967142?= When determining worker_pool->id using idr_alloc() in the worker_pool_assign_id() function, I think You need not to pass WORK_OFFQ_POOL_NONE to the idr_alloc() function. This is because the idr_alloc() function checks the maximum value of id as INT_MAX. WORK_OFFQ_POOL_NONE is equivalent to INT_MAX. So, I think Any code related to WORK_OFFQ_POOL_NONE is not needed. static int worker_pool_assign_id(struct worker_pool *pool) @@ -555,8 +555,7 @@ static int worker_pool_assign_id(struct worker_pool *pool) lockdep_assert_held(&wq_pool_mutex); - ret = idr_alloc(&worker_pool_idr, pool, 0, WORK_OFFQ_POOL_NONE, - GFP_KERNEL); + ret = idr_alloc(&worker_pool_idr, pool, 0, 0, GFP_KERNEL); if (ret >= 0) { pool->id = ret; return 0; @@ -735,8 +734,6 @@ static struct worker_pool *get_work_pool(struct work_struct *work) (data & WORK_STRUCT_WQ_DATA_MASK))->pool; pool_id = data >> WORK_OFFQ_POOL_SHIFT; - if (pool_id == WORK_OFFQ_POOL_NONE) - return NULL; return idr_find(&worker_pool_idr, pool_id); } Please check the above. Thanks, From JaeJoon Jung. diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index a0143dd24430..ac65e66f8fc3 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -79,7 +79,6 @@ enum { WORK_OFFQ_POOL_SHIFT = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS, WORK_OFFQ_LEFT = BITS_PER_LONG - WORK_OFFQ_POOL_SHIFT, WORK_OFFQ_POOL_BITS = WORK_OFFQ_LEFT <= 31 ? WORK_OFFQ_LEFT : 31, - WORK_OFFQ_POOL_NONE = (1LU << WORK_OFFQ_POOL_BITS) - 1, /* convenience constants */ WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1, diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 7cd5f5e7e0a1..c38e93266987 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -546,7 +546,7 @@ static inline void debug_work_deactivate(struct work_struct *work) { } * worker_pool_assign_id - allocate ID and assign it to @pool * @pool: the pool pointer of interest * - * Returns 0 if ID in [0, WORK_OFFQ_POOL_NONE) is allocated and assigned + * Returns 0 if ID in [0, INT_MAX) is allocated and assigned * successfully, -errno on failure. */