Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp120697rwi; Wed, 12 Oct 2022 17:07:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48KrL1LiMt976wg0E7cqu0QZUWRsCqyvutAfaxPBSfj4xOgQhT5pIGSGVbJSwOL6fgkaZp X-Received: by 2002:a63:d845:0:b0:44b:d074:97d with SMTP id k5-20020a63d845000000b0044bd074097dmr28510317pgj.32.1665619665682; Wed, 12 Oct 2022 17:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665619665; cv=none; d=google.com; s=arc-20160816; b=yfNdDpyVHCL8jd0zUoiB0ASbF16gxrfi7uELlHRjS7ggty8tbCSZgC2XLSDRqaTPpB 0+jyBJKDk3zANod0EBfo62ZiHQKvHYX3v5eUHHzgkGnO6xnJeZ5ifOcXMJow8G8lEt31 raq2uLT4Qmr6Kd5ifN1KkNPFL7/hq5YBA9kS/XERXlGAY/LJ+jbg1SaHBKzxknQmIOw7 W3o3r/hcKVdHSNDALsp2Lwz2tk+Ld7oExIudIlw7Kdl0PvlnxVZhBpraAHw1unkWeHmx o3xM0SNB/plZldJxHq2kSjR1mpsuQTr+V68UnpL3TH7wSmNLpxgQhhylr7NMLCNNQmW+ cBvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HTHHr/MWxMd0iit2mQfPzchuu/gnFAYaWicjCw3O9Rk=; b=yy7RwExpwHSV/F2uI+1s/3dEI9yF9nQBmm0Y1RBWl8FqpFMJvGHJJ40ZGW5LudOzR7 YqrtFq6zJ1vQ6dxWcTwaV+kv5vZVUIxu00AC55NWUWmSvmYSXG4IA1qA31zMFPOsnQDh SEseUxmqKaViNTxHCz10RlC6FKNtXjtfCjOTkFjvY3DYAEykYM8am2GZThulXvwcStQW WRaWAxnpbfIR8bsD5Yc/0KO70B0JHITTTXgMtAOkSsdxnfKvlgCEol9AbR1g+KFtiVNT rdkuz0qCEom+lFccDZwbsZGmhZWekkkaPADt4mKIpf0z77qUj9gBu8aB7FXFPIXuXLKE hfOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=WwKieyq6; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a056a00234d00b005636ce48882si11991330pfj.45.2022.10.12.17.07.30; Wed, 12 Oct 2022 17:07:45 -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=@joelfernandes.org header.s=google header.b=WwKieyq6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229657AbiJLXzD (ORCPT + 99 others); Wed, 12 Oct 2022 19:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiJLXzA (ORCPT ); Wed, 12 Oct 2022 19:55:00 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91CDA27145 for ; Wed, 12 Oct 2022 16:54:58 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id j21so155770qkk.9 for ; Wed, 12 Oct 2022 16:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=HTHHr/MWxMd0iit2mQfPzchuu/gnFAYaWicjCw3O9Rk=; b=WwKieyq6thYuR2x+u6cnHGLiFETZ8wGw39vL83H0ji9AvWeFzn8/BwVhy6WQPR/gHH r5VGVqR+n3eQWCnaF52CAcfUb+ET/wZrRzyn1vmtYBGuejll8QFVUgzK57orunlKsdyt vIHEmccnxEGj76jdRfOOWP26+ePsTNrfYhiys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HTHHr/MWxMd0iit2mQfPzchuu/gnFAYaWicjCw3O9Rk=; b=d2nzzFakpKwLDg/tisqbQlNWi3s9rtgXc5KYYPOYdzDXunSDb4R9DcDzKQRZHMC2Na UtXk7uFdIBQrBdBfdl2TUPOXSqbCM+c7BCJdHqa18CxPHkhRUv2GT05EcG/amnPG2ABa CNHeq0pS+YhHrxhxP4yfNZyFiqZIU/CymfBcTWRHOVG8DUfoiitBx7dmAtBBbsyg/VTq HewvUCgDcB1lXOIa4xe53YWy37DnXa2e5+Pr7wNugrd+t0vTCwGLAEuqxnPZO8fcZvGn qXwNOfsij3hcrkfREeHIX3f90bNDloFNbgx/gz9DuPO9Y7URlKgjWRt1ILQXbmN8ar6P +5Mg== X-Gm-Message-State: ACrzQf2A6YlNZGfRP9l/lqSCy6fTxECAfHADXIvMJBJQnv3zu3CZRR9T vmifd+giqU8XwP5S9IRJCauSIg== X-Received: by 2002:a05:620a:2903:b0:6cf:920f:435c with SMTP id m3-20020a05620a290300b006cf920f435cmr21743122qkp.741.1665618897718; Wed, 12 Oct 2022 16:54:57 -0700 (PDT) Received: from localhost (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id j4-20020a05620a410400b006eea4b5abcesm2290428qko.89.2022.10.12.16.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 16:54:56 -0700 (PDT) Date: Wed, 12 Oct 2022 23:54:56 +0000 From: Joel Fernandes To: Waiman Long Cc: Connor O'Brien , linux-kernel@vger.kernel.org, kernel-team@android.com, John Stultz , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Will Deacon , Boqun Feng , "Paul E . McKenney" Subject: Re: [RFC PATCH 01/11] locking/ww_mutex: Remove wakeups from under mutex::wait_lock Message-ID: References: <20221003214501.2050087-1-connoro@google.com> <20221003214501.2050087-2-connoro@google.com> <73859883-78c4-1080-7846-e8d644ad397a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73859883-78c4-1080-7846-e8d644ad397a@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 On Tue, Oct 04, 2022 at 12:01:13PM -0400, Waiman Long wrote: > On 10/3/22 17:44, Connor O'Brien wrote: > > diff --git a/kernel/locking/ww_mutex.h b/kernel/locking/ww_mutex.h > > index 56f139201f24..dfc174cd96c6 100644 > > --- a/kernel/locking/ww_mutex.h > > +++ b/kernel/locking/ww_mutex.h > > @@ -161,6 +161,11 @@ static inline void lockdep_assert_wait_lock_held(struct rt_mutex *lock) > > #endif /* WW_RT */ > > +void ww_ctx_wake(struct ww_acquire_ctx *ww_ctx) > > +{ > > + wake_up_q(&ww_ctx->wake_q); > > +} > > + > > /* > > * Wait-Die: > > * The newer transactions are killed when: > > @@ -284,7 +289,7 @@ __ww_mutex_die(struct MUTEX *lock, struct MUTEX_WAITER *waiter, > > #ifndef WW_RT > > debug_mutex_wake_waiter(lock, waiter); > > #endif > > - wake_up_process(waiter->task); > > + wake_q_add(&ww_ctx->wake_q, waiter->task); > > } > > return true; > > @@ -331,7 +336,7 @@ static bool __ww_mutex_wound(struct MUTEX *lock, > > * wakeup pending to re-read the wounded state. > > */ > > if (owner != current) > > - wake_up_process(owner); > > + wake_q_add(&ww_ctx->wake_q, owner); > > return true; > > } > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index ee28253c9ac0..617e737392be 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -1013,6 +1013,13 @@ void wake_up_q(struct wake_q_head *head) > > wake_up_process(task); > > put_task_struct(task); > > } > > + /* > > + * XXX connoro: seems this is needed now that ww_ctx_wake() passes in a > > + * wake_q_head that is embedded in struct ww_acquire_ctx rather than > > + * declared locally. > > + */ > > + head->first = node; > > + head->lastp = &head->first; > > } > > You shouldn't do wake_q_init() here in wake_up_q(). Instead, you should do > it in ww_ctx_wake() right after the wake_up_q() call. > : Exactly, it is also mentioned in the wake_q.h header: * The DEFINE_WAKE_Q macro declares and initializes the list head. * wake_up_q() does NOT reinitialize the list; it's expected to be * called near the end of a function. Otherwise, the list can be * re-initialized for later re-use by wake_q_init(). * Thanks.