Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4116626rwd; Tue, 23 May 2023 03:26:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fLyzXcm9mfdYUc2tKy66Hj162ybnXllHuBoiZutpUKtMsqvUQzg8YfTueKVpLGV6sd4jW X-Received: by 2002:a05:6a20:3c89:b0:10b:b2fb:68fc with SMTP id b9-20020a056a203c8900b0010bb2fb68fcmr6013205pzj.53.1684837600726; Tue, 23 May 2023 03:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684837600; cv=none; d=google.com; s=arc-20160816; b=Q8+/O0qHP1IX0I6LPsGA5ZWmKe5PLvTbE8v+6eGPcDYJ0SRslLNI3cadipbdlsVHeB Zfo80SNgS8YiLbKjwRTCXbHeP2AzIQ9oi1QhjlaliNb2PNAenfpo71Vqu1moBtygjmos YpV9foZzYGTGTFixn8JqCNCq4nqTAZG/fHdxtdDkyiRheVnA4Kd89MS7CWCGwjqXtgAO VQb+WeY72GFKa+i/xv0ZnL0sBW639r5oI1lprbcaMBq6qwhv3Kt0crRmmdkqMTnVZK73 AFR7hna/Mph1UAC4IP2Yez/VIfbJmqWRmbenSNj+sHzsTdaIjciIiKOPIF4gRqeWcTqf oFmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=lhCkMkjn9VMpJcOKlJHl3OXu9zjlWEVVFontZ/bb8KQ=; b=Dce9L6IVXfeiP+QSZJLaUrCRNa5WXWjLrtb5fD4Epvj7TK+Lw0CzXZCSqrvgYo/QAg dBd5DCq1kwzR1RLey0hPa/77Ah9AJdK3VpwltIttamv+zoiEQWhMzwd1FvzPQ5pYKNvB 1fP6zKDHf9bti5Itz4wQD5ujL7aBlGDlWTlx68S4y6c6L4DAHvL96+ppWRJVgmHgyuj6 C0+ysomS0f4Th1vEg29uGN/iN1BlPBH61ZjXoVR0K83/vnCUCagwL75xn5TWh9ne5yjo lAeWYRMjNcja3xbRoXqaogvlLRXQTaXWJiloEFLqv6VCuRhpE4In73GiKfytsdE+UtbD lZdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=akE++w3z; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q22-20020a637516000000b0053ba833a8bfsi2824701pgc.531.2023.05.23.03.26.26; Tue, 23 May 2023 03:26:40 -0700 (PDT) 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=20221208 header.b=akE++w3z; 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 S232374AbjEWJzU (ORCPT + 99 others); Tue, 23 May 2023 05:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236433AbjEWJyl (ORCPT ); Tue, 23 May 2023 05:54:41 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A4B1129 for ; Tue, 23 May 2023 02:54:22 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ae3f6e5d70so65295765ad.1 for ; Tue, 23 May 2023 02:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684835661; x=1687427661; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lhCkMkjn9VMpJcOKlJHl3OXu9zjlWEVVFontZ/bb8KQ=; b=akE++w3zqrtnAR5tMBTtEAWvh9lJ97qKebndyx7Rm38WPYp+hcaSqH00ON0mxKZCMr 2mW/7sErwYYuyBGQ4TOHPkGSRTIU11JThNY1XAaZmAJcRcWiK5HMR9i1hdeVBKNP4xT5 +Mn/mBLNqDirTGAYlC82Vg2cbrUmIYH2oHOonfHMvjgFw4Vmp8TGFBC8UGZgRfNZko3z SdUpLklWmjmGl4zJbNmFjS5mjIq8Rb5Ua9l/ooNVb53gT1mgmEP9PFUO9mW+UAtbcdf6 hvwDsMiSOb0JIcw/mQtNp1yk9urAYIRfb4AD17+2mHjYhObd1XrgLoohVeSg6n8FGW/G HH2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684835661; x=1687427661; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lhCkMkjn9VMpJcOKlJHl3OXu9zjlWEVVFontZ/bb8KQ=; b=D2TeRwquO1OJPP6phs4x6Y+k50bzKUpifT+ct0m4GJQsLi1kXCXZol17OQXLPLTHUU 2/E/P/PIdwjUE9vGR+pB1TzkYxOHGx2ZHwR8sxu6h2rzZfWhp1pMX1iyAp9E7TsPr7Nl nPT+9Kr9+JE+t6mi91DSzSy2v1/C7NYr/UrZ2FqPN9IY6QPUeknWYwA1gF4OWywY3+0w T2BlXuMx/sNZoLnjO8f40HuFQjX/vS7k07AX+APT9pfL/305qjrT0oYdrfRWQMv95yNq haU5P4xEKJ4z+Ejijh5UBtzH9GKygf5BWfCJQBu242GFbrPbTgHiv3YeXWj2fvIS6Ip6 /hRg== X-Gm-Message-State: AC+VfDxtH3chZFPzjDD5tSDGPL4XMl7LBUrXAliaAgeajiPsSR+WtzP3 gdzRy50GFTL1JPDoy9lNFvgx3X485FTcIdxNCVU= X-Received: by 2002:a17:902:e9d4:b0:1ac:b0c5:77e5 with SMTP id 20-20020a170902e9d400b001acb0c577e5mr12979545plk.68.1684835661414; Tue, 23 May 2023 02:54:21 -0700 (PDT) MIME-Version: 1.0 References: <20230519001709.2563-1-tj@kernel.org> <20230519001709.2563-4-tj@kernel.org> In-Reply-To: <20230519001709.2563-4-tj@kernel.org> From: Lai Jiangshan Date: Tue, 23 May 2023 17:54:10 +0800 Message-ID: Subject: Re: [PATCH 03/24] workqueue: Not all work insertion needs to wake up a worker To: Tejun Heo Cc: torvalds@linux-foundation.org, peterz@infradead.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, joshdon@google.com, brho@google.com, briannorris@chromium.org, nhuck@google.com, agk@redhat.com, snitzer@kernel.org, void@manifault.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Fri, May 19, 2023 at 8:17=E2=80=AFAM Tejun Heo wrote: > + pool =3D pwq->pool; > + > /* > * If @work was previously on a different pool, it might still be > * running there, in which case the work needs to be queued on th= at > * pool to guarantee non-reentrancy. > */ > last_pool =3D get_work_pool(work); > - if (last_pool && last_pool !=3D pwq->pool) { > + if (last_pool && last_pool !=3D pool) { > struct worker *worker; > > raw_spin_lock(&last_pool->lock); > @@ -1638,13 +1636,14 @@ static void __queue_work(int cpu, struct workqueu= e_struct *wq, > > if (worker && worker->current_pwq->wq =3D=3D wq) { > pwq =3D worker->current_pwq; > + pool =3D pwq->pool; The code above does a "raw_spin_lock(&last_pool->lock);", and the code next does a "raw_spin_unlock(&pool->lock);". WARN_ON_ONCE(pool !=3D last_pool); can be added here and served as a comment. > } else { > /* meh... not running there, queue here */ > raw_spin_unlock(&last_pool->lock); > - raw_spin_lock(&pwq->pool->lock); > + raw_spin_lock(&pool->lock); > } > } else { > - raw_spin_lock(&pwq->pool->lock); > + raw_spin_lock(&pool->lock); > } >