Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1458712rwi; Thu, 20 Oct 2022 12:45:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4T2pi+ycc6CDZQda+nb4u0St6fljXtUcBZaJS0is649v40DSamBnk4G57fdCOvgCt7Cch8 X-Received: by 2002:a17:906:9746:b0:78e:11cc:3bb3 with SMTP id o6-20020a170906974600b0078e11cc3bb3mr12386890ejy.379.1666295158752; Thu, 20 Oct 2022 12:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666295158; cv=none; d=google.com; s=arc-20160816; b=vYFBkdMptHWyQPZo59shEExSM8q4a3HYURlcfMwsnK+JWDFc5+KQ5Sb2/0Uldq0emp gvDo8RNxd7lKgiulqgf1ZGndoycNaQcYFaq9gUoYX6G9glPy/c8pEBDHUnImK3S7kVZU 2xBkd3d0wO3M/v5rW3expEQz/hpkFMHkdZMwavptKMT4dP4t984tqw2eWz8kSM71HHI5 NsD/t6gq6TpzOKSpS7DjiOxd+HGONfj8O3cNICtVc4F+oknIdgv3wKfMHvCD9kP74WSM BmSfFYLclEed3vSybk2mTRh0uyY3qoV1m/Qs1+1VjYzEUXfFe2xPU+VbbBffBh+dgiry QrZQ== 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:in-reply-to :references:mime-version:dkim-signature; bh=a4MNsuWXvt+bS3agOGU3z+N2CwGZIxCInLkhAMhqwl0=; b=AM6CVOHM2qs3pUFZ5O1FKIzVA8LvI0cYeiKJEer2P7Y2NR553qc/7GjSnsMPC9VoSA N4DrlZEO/1lX7K2kHrxhGigFIqc6JR7B8kPpmweVr7bWG2DnkL651G6uyp1DLJJFaHd4 pFsgiv3RRx7FXz8uU/vzuFiw2agOfS6M9ETkc1UmKLfPdK6odRZNM5IymoB3uQZOqaTT qRY20Ure/jhcQjtdqppDf64VRkF+wTJRiW1DzxkQQTrrSpDlk7MtlDfpCzU7SkpX1qjY mRMMRwDsobCbPe4iTY/8WJ+SGYozDWWX2dNWh7OK53eVGDM8QsRG1Pym4MQjcmLXZv4A 1+4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Ug8LDle/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a1709064fca00b0078db1258ae9si21059366ejw.555.2022.10.20.12.45.32; Thu, 20 Oct 2022 12:45:58 -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=@google.com header.s=20210112 header.b="Ug8LDle/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiJTSni (ORCPT + 99 others); Thu, 20 Oct 2022 14:43:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiJTSnh (ORCPT ); Thu, 20 Oct 2022 14:43:37 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68E1D208817 for ; Thu, 20 Oct 2022 11:43:36 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id fy4so1668355ejc.5 for ; Thu, 20 Oct 2022 11:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=a4MNsuWXvt+bS3agOGU3z+N2CwGZIxCInLkhAMhqwl0=; b=Ug8LDle/yVBuiKK79Ei1HiwQqWtE9+BFTn8qtqeyTo+OZOZQ0/5ECS8+MR8vbahV9A NFiFsNGEAY4t1LXeJ0vjZ3+1vDtu2oZ1XhE0Pn53dlSSWTH3pxRK6kmJh/DtDGwoDGK8 DsAWna/UKmgZ0UDWvzjabdTRRmwg8fu0CoGL8hJgQnDpfjLJqwEfRUNOgpUQIuKM1ziW Nw6oJ7VqaHAVMWfYxgMIvN3reS4aLhiBG6dPd5mxKIzYH1LIcorjvpZPoJINrtqJfdON gjMSUHwKl6ru6qp5XQwpDcpqbYCHKQzt9ARe3c9c+71FbP8o27B6vV3Q+pY0esxjb6fb ciCA== 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:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a4MNsuWXvt+bS3agOGU3z+N2CwGZIxCInLkhAMhqwl0=; b=x3QIP4MzHW9Trf8unniZ7NSnOY+SC4M3fI1ZcZN5K54IYvHBExXvaWUQKr/sFlyrMP ppXVjcYBrSOI04KGEH4V4GmxD34QMP/MLFrgHBPO6si1F3267T+9bieWha+KL7mrSSPC HGm8xG/4Ta3QpXYSPP7XWsPA9YNltaWC4JggqzbO9WwVsfl0vb5BfuxUDkjWwv9vKg/T mKWL3ukVIGvnO6Z5EqHxfrgnsX8yTmK7QIVJ7gSk5gP8K2XYU+uRSKDkaihomsgqEdId 17O69hWF3z5cT3W9IWcAr/17fRVeAFS4KuseV6xrlgQeXdaWqo1gfmwy+IiDC6LyX8rd mnFw== X-Gm-Message-State: ACrzQf2rNGdDIaIwtZ6zeBStrV/SAVqJTgeqp18MyxpShVZ3lyvKY9O6 GDH0hniaMZKp88PJ0ZZWg43FRGgdZpq1GJhlkKlTiQ== X-Received: by 2002:a17:906:fe04:b0:777:b13d:30a6 with SMTP id wy4-20020a170906fe0400b00777b13d30a6mr12022670ejb.248.1666291414788; Thu, 20 Oct 2022 11:43:34 -0700 (PDT) MIME-Version: 1.0 References: <20221003214501.2050087-1-connoro@google.com> <20221003214501.2050087-2-connoro@google.com> <73859883-78c4-1080-7846-e8d644ad397a@redhat.com> In-Reply-To: <73859883-78c4-1080-7846-e8d644ad397a@redhat.com> From: "Connor O'Brien" Date: Thu, 20 Oct 2022 11:43:23 -0700 Message-ID: Subject: Re: [RFC PATCH 01/11] locking/ww_mutex: Remove wakeups from under mutex::wait_lock To: Waiman Long Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, John Stultz , Joel Fernandes , 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" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 4, 2022 at 9:01 AM 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. Thanks, will fix this in the next version. > > Cheers, > Longman >