From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98395C43331 for ; Wed, 17 Mar 2021 14:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5051C64F26 for ; Wed, 17 Mar 2021 14:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbhCQODf (ORCPT ); Wed, 17 Mar 2021 10:03:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58797 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231690AbhCQODO (ORCPT ); Wed, 17 Mar 2021 10:03:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615989794; 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=VF+i/IaqQthDr1vis77vksrogzlo56uC4vmzTlpomlo=; b=DcyLCbdu87KwN2DR0rtvt8V7NrVm4VGr+XRfK2m/cwK+jcbK8OOPsXEN2o5+bj4qPA2rDi Vp9vTpFOn3wSYODhGhdjpwXK5lzGk1Uz4vMeb+NVRhnCCUKUYgGcWUff4d17pSPhgFNnf7 wtgALsDZsC5md0ttutXAvahYNCqHOzM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-z8lXiLtTNtu6mdsHtj4IIg-1; Wed, 17 Mar 2021 10:03:09 -0400 X-MC-Unique: z8lXiLtTNtu6mdsHtj4IIg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22617180FCAE; Wed, 17 Mar 2021 14:03:08 +0000 (UTC) Received: from llong.remote.csb (ovpn-117-171.rdu2.redhat.com [10.10.117.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88B4E5D752; Wed, 17 Mar 2021 14:03:07 +0000 (UTC) Subject: Re: [tip: locking/urgent] locking/ww_mutex: Treat ww_mutex_lock() like a trylock To: Peter Zijlstra , linux-kernel@vger.kernel.org Cc: linux-tip-commits@vger.kernel.org, Ingo Molnar , x86@kernel.org References: <20210316153119.13802-4-longman@redhat.com> <161598470197.398.8903908266426306140.tip-bot2@tip-bot2> From: Waiman Long Organization: Red Hat Message-ID: Date: Wed, 17 Mar 2021 10:03:07 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/17/21 9:31 AM, Peter Zijlstra wrote: > On Wed, Mar 17, 2021 at 02:12:41PM +0100, Peter Zijlstra wrote: >> On Wed, Mar 17, 2021 at 12:38:21PM -0000, tip-bot2 for Waiman Long wrote: >>> + /* >>> + * Treat as trylock for ww_mutex. >>> + */ >>> + mutex_acquire_nest(&lock->dep_map, subclass, !!ww_ctx, nest_lock, ip); >> I'm confused... why isn't nest_lock working here? >> >> For ww_mutex, we're supposed to have ctx->dep_map as a nest_lock, and >> all lock acquisitions under a nest lock should be fine. Afaict the above >> is just plain wrong. > To clarify: > > mutex_lock(&A); ww_mutex_lock(&B, ctx); > ww_mutex_lock(&B, ctx); mutex_lock(&A); > > should still very much be a deadlock, but your 'fix' makes it not report > that. > > Only order within the ww_ctx can be ignored, and that's exactly what > nest_lock should be doing. > I will take a deeper look into why that is the case. Cheers, Longman