Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp694249rwb; Tue, 4 Oct 2022 09:20:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7L8kGMUhYKVvNOOm9e9t5RyxeC55EvAi/FqFrmVeFqIPs/GK4i84fmgpTkpTKcXQH6FDva X-Received: by 2002:a17:907:788:b0:741:4d1a:595d with SMTP id xd8-20020a170907078800b007414d1a595dmr19381582ejb.737.1664900430300; Tue, 04 Oct 2022 09:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664900430; cv=none; d=google.com; s=arc-20160816; b=VBW1b+OupolwOynN8jEvQWA6s4xdlrWyCYVwnj2JvJx0aN0GH2S0iVBZbpME7jKdkT ypIvSKLDg19tMPcbUhg58WBKjog3kb+3MO5lQg5zZz6dSNjlPytGvCiBMy6Mq2Q9NFEs 9odliWK4se1czLTmXAW8lG1dSMP8fSr85wvmGmeJXnwDNaz9Uw7kzojuVoQPFqiNRt1C pQSkdYCBAjFWY60KN/m9jHlDhXe+8TFFaGGdUvpY9nf9futZG2LL60e62VvOHq1BqD5J PzvvoIqkXjrdSzCByqqG0onfXt9MEN29ltiiQJOCPXlsL1t8FPYImb1IRh+aZIfW1oaz 5ZDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=xM+zyAOnxDRj+m9eSoILBxLQtaLNaq//fM/4R+jhI8M=; b=0GjnATY+T6lKrswT/X3brm8swzsgaxIjsXDyz0L8pmD7mgvT801WQ7ptvGW4AO8HqC X8fq8Kc3tk8/nVlITeMrtWq6hFWIQ678QSt7JrlsXhcTpT3vHJlThTWSa4W5x1T2oTDS sBJzTSlz9SBfPwr5sASdppvGpBK92uixi20bpMkLl4B4M4KUKZXdh2KkVI+uP1a0HrP5 mS1WpxiGcDveqfb7lbu/Oky2QCKD5fSTKOPV+YEmGaXtpGt2y9deL0rY8v0+6KIYibFx Ve01ff3oDPS37hDyUsHdtNgAfY1E344WC5rhaxai048SGr7tOTXaNduq8JUrphEfbVKn Rgzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C3PO2l2d; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs14-20020a170906dc8e00b007824b85978asi10448773ejc.81.2022.10.04.09.20.03; Tue, 04 Oct 2022 09:20:30 -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=@redhat.com header.s=mimecast20190719 header.b=C3PO2l2d; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbiJDQBZ (ORCPT + 99 others); Tue, 4 Oct 2022 12:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiJDQBU (ORCPT ); Tue, 4 Oct 2022 12:01:20 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA1D16053A for ; Tue, 4 Oct 2022 09:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664899279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xM+zyAOnxDRj+m9eSoILBxLQtaLNaq//fM/4R+jhI8M=; b=C3PO2l2d4SlXvpLkCLCvwKpX6tEAiVkY+SbSWX0/OKF2+7vK2ZnwTphbmoXnbJ4t67GQTc I+KnowwZPeNqSD4vSyMPTD+pbWWiknqUG71l/fMfTNXW5dojkNGVkl7Kc8NishRJcy+5PB ps+Gk2pkFesr71W/nE/5deOCkBpU3Fc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-r4qG9XG0MBiXZ3Jn18jrww-1; Tue, 04 Oct 2022 12:01:15 -0400 X-MC-Unique: r4qG9XG0MBiXZ3Jn18jrww-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18F79299E76E; Tue, 4 Oct 2022 16:01:15 +0000 (UTC) Received: from [10.22.10.217] (unknown [10.22.10.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33BD12166B26; Tue, 4 Oct 2022 16:01:14 +0000 (UTC) Message-ID: <73859883-78c4-1080-7846-e8d644ad397a@redhat.com> Date: Tue, 4 Oct 2022 12:01:13 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [RFC PATCH 01/11] locking/ww_mutex: Remove wakeups from under mutex::wait_lock Content-Language: en-US To: Connor O'Brien , linux-kernel@vger.kernel.org Cc: 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" References: <20221003214501.2050087-1-connoro@google.com> <20221003214501.2050087-2-connoro@google.com> From: Waiman Long In-Reply-To: <20221003214501.2050087-2-connoro@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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 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. Cheers, Longman