From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C94923ABDA8 for ; Thu, 28 May 2026 13:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779975718; cv=none; b=knmc8ecCx9eLk/lsgVinLNry1Hb/mr1KIM8XgLlSRIDU1hTkxiRXNPHu/3NIO0pBQxkw2hNWAoX7PUVtCOfu7JDWxPXl1h5nI+o9OMlNSeIfZ8f0gVXmDndeL8vfUgxbGu6pfJPTRMrAoFbj3+cS0tqYsYmXtDgIpCAIiFiam44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779975718; c=relaxed/simple; bh=xYdbApSWDi5C3+Uv+jJ689TLfu5ri1VhieTV7Fu293o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nMT87/d1BNZn1XFvdli3DSkdpcPWKInpAYp3kREjbVx6IIMaEFBotV9f2LchnvcWuFOjQflXzAv0Sf4iRSQYzDhPBH6ApGfW3nLUYcY3nyjd9cHmHCZHNBEybVTOvEPP25M4eu5RDCV8b/rSxeNH2gafwxS/VLgHxY3sd8RNV88= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-68b73f1a8ebso605161a12.1 for ; Thu, 28 May 2026 06:41:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779975715; x=1780580515; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RmwcUECNXWlP1kIDN76xySJotR5IRz+TJWqfr/yutJ0=; b=K818LHmBzJkoVJ3HzTVLCWjIEIgmmH9WzFcQ5AnY34j66wntHEXDNvKz2WxXaTxJij vfnRybGb9l+DYetZEiODGlB7rmkVRmdDB0YLxHuw/ZHeucjxjxreKPRS1GHlYNSm+KjK iFqTl4Bf+GCfMY2H4X+c9dI70L0RrHezDa050Dg/IeyGf+2s1Xhg6JI6xWzipscmHS9p tyeWNfme1CyPL5txazgRzQV3X7YDQplSZZFYavAE3dhZkaxD4YTCQqQetYptH12I1YAa 7JNY+6Y4CiIzAqElZbpAGWwMzJhQzQ4d5aJy4MFOfMGGL6o5b4vEzsKzGeQC1fxQrgxk kHKg== X-Forwarded-Encrypted: i=1; AFNElJ93N/ihDyOnpFt6kWsc7x2nFNFXL9yD6BAOg2M7Mb4WhlW7Kem+TcwJhPcxBrx+4q1ZbnUsuW07GlU9yBs=@vger.kernel.org X-Gm-Message-State: AOJu0YwYyfADkGSKCHFaQynKZfVfZT/8YZmCKwhA6Cs+A1bvmS3Elsm6 53uVMuYK7cxH2FNpcRd234RLntQYjDVE5Nq+SIuHFRtZZc2mLR55WOPTAc2o0eMJpBE= X-Gm-Gg: Acq92OGRo/zhxjmzFdaKYM+J0JvKX9qV0EgdaTRx0ydroYERRrg6HF4LwkTiP/lDdPK 9yX18eUM4HGR0JfZIgJj25Zrhh367LO0rYjWff9tcDOuBAY7U4GKixCeA3Y7CC08PJf2IaTzf4K kwdVYOJPN81a2FoO2wDfXD90WIrg3GGN+LGRigjT7JdvZ+PzFCSCYRWW+40s4ox6c3PE3w5/8VD Ag2aZLbAljp4Eld24qDRSVmDV7BgDaHL9522ODfTlz5cnShZTnN2zpVVSWJPMmOJCRrKb9vNiSo A8fdDrbFs7gzNdw6KjdfM42ZlfCZPvsFL7XJL9kp5Mmdt8ym2V7QsAO5ZrTzP2II5ek1A3hPTX/ IDFJV/0UL7TPYF3oDaefxb9QoK5JMPIzGEPxzwxQ0tcUfm5Axw/DVw8xO4SvR0rytxMnAd0BoOy rvtDI+p6f+GFRvyr5nVm9oGf+ndHtGXqiRUX9c X-Received: by 2002:a05:6402:3513:b0:670:8b48:182a with SMTP id 4fb4d7f45d1cf-6889c420dc6mr14970488a12.4.1779975714940; Thu, 28 May 2026 06:41:54 -0700 (PDT) Received: from gmail.com ([62.197.47.167]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-68b9d51a60csm153071a12.11.2026.05.28.06.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 06:41:53 -0700 (PDT) Date: Thu, 28 May 2026 14:41:52 +0100 From: Breno Leitao To: Sebastian Andrzej Siewior Cc: Tejun Heo , Lai Jiangshan , linux-kernel@vger.kernel.org, marco.crivellari@suse.com, frederic@kernel.org, kernel-team@meta.com Subject: Re: [PATCH 2/2] workqueue: defer wake_up_process() outside pool->lock on hot paths Message-ID: References: <20260526-fastwake-v1-0-e69ad86923e6@debian.org> <20260526-fastwake-v1-2-e69ad86923e6@debian.org> <20260527152205.OjEsPVjM@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260527152205.OjEsPVjM@linutronix.de> Hello Sebastian, On Wed, May 27, 2026 at 05:22:05PM +0000, Sebastian Andrzej Siewior wrote: > On 2026-05-26 14:08:06 [-0400], Breno Leitao wrote: > > --- a/kernel/workqueue.c > > +++ b/kernel/workqueue.c > > @@ -2423,6 +2424,15 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, > > > > out: > > raw_spin_unlock(&pool->lock); > > + /* > > + * Issue the wakeup after dropping pool->lock to shorten the > > + * locked region on this hot enqueue path. kick_pool_pick() did all > > + * of the work that required the lock (worker selection and > > + * wake_cpu setup); the wake_up_process() itself only needs to > > + * take the target rq->lock. > > + */ > > + if (wake_p) > > + wake_up_process(wake_p); > > What about using wake_q_add() to grab a worker(s) and then wake_up_q() > to wake the worker outside of the lock? Thanks, this is a good recommendation. Looking at the API, I understand the intended pattern is to call wake_q_add() while still holding pool->lock and then wake_up_q() after dropping it -- wake_q_add() only does a cmpxchg on task->wake_q.next plus get_task_struct(), so it's safe under the spinlock, while wake_up_q() is the part that takes rq->lock and is what we want outside. Will switch to that in v2. --breno