Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1843954rwb; Tue, 29 Nov 2022 21:11:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf4uzQRTHcNX9osuBvxDzzUv08kOuMZokL1kktskRUlszJ8o50IEhJg5J5DksA1I9TfUAf5a X-Received: by 2002:a63:d255:0:b0:477:d17b:414 with SMTP id t21-20020a63d255000000b00477d17b0414mr23604008pgi.503.1669785098344; Tue, 29 Nov 2022 21:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669785098; cv=none; d=google.com; s=arc-20160816; b=eV1kwAvnQgDE7UPLrREpQPSoBVUh1pppgv4zOG8i9u1L0y7i3qk54m7FbOfFVxgAK/ QRYWY6cegtNvJgaZylyt7LdHYT0srBae2TuPlxoD0e/4cyV1ww3M83cMeN2zvgx2oPnx g6INcL9jBbhq1rRqmfQ0BSz4UAfWxs47oy+r4wt3iMmojNh52ndUDY4dOOVR9Zbu1ZnO 0I4Ske32EfmECjRRfnRzjRCsrKJvTMjXT4pU9Ixc7Wgv5BilT/T7o557u6GsTppWvcpN ao+eXRd3o2YQhqDGnSTxU1tyKDTwDfjRMS/Z5RWZjZRsWaViK1NoHoUk/Ajnb9NUm5Tu 0C/g== 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=AQfI9itT56aGkQXPmrJoqcBSs6MMztV/FP9e3fo34YE=; b=BmENgUm4GOUrAuy45bfp8m6GuIOAImwB6ySd0zXcE7hDOGpAMCjT4c5j2R1XY5Dd8g YWk/CWEmBvpQJRd2VtTXdg2QwPUc4KfjFBBfQZZythd2xtwW5soMMHS3ezFWSPIN/M5Y YgtMDjx/8QB5xcsT2fVHecBby7FgzFcueDJgWbHIZ5FwLe2M0weFEyKlZR8CbIuwwUvn GxpDMsNHw9gGIfgnvQaGwemyf1qTaAbcwg6yX/rsWLG5vvRFEYDzbBFUPUI83IC5lQTS 02w3dWvpP0/WqRNILpwfCa6/r+UPT+A1n7JsiV2o8Xrq8/0JA9xNhuzHmjz4KcJE3dOC zKxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gfcNra0c; 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 x69-20020a638648000000b00476e845a78bsi358792pgd.126.2022.11.29.21.11.28; Tue, 29 Nov 2022 21:11:38 -0800 (PST) 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=gfcNra0c; 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 S232888AbiK3FC3 (ORCPT + 84 others); Wed, 30 Nov 2022 00:02:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbiK3FC1 (ORCPT ); Wed, 30 Nov 2022 00:02:27 -0500 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93D006F0FA for ; Tue, 29 Nov 2022 21:02:26 -0800 (PST) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-3704852322fso160022267b3.8 for ; Tue, 29 Nov 2022 21:02:26 -0800 (PST) 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=AQfI9itT56aGkQXPmrJoqcBSs6MMztV/FP9e3fo34YE=; b=gfcNra0cbSMcEsa9a6u7N6E+fn9tqIWr7b5nZhCPU+3qqkjLm76Gro9nvAwB0oGlq6 k6Xnd4JvXTRnEXry2GvzBvSf2gusHv164kEtbCgPrXC6zr475X/EPwsWTjr4GmzL8s0L 3bQQVffgXdW1LqoKMsZpgDqOwaDtDtuBvxbt6Gp1fwZ0PGDLRdUAjrgcWellpuoB4SXW kvIsFCAIivvJMAtSwH4d4t930DuuIeLxWjNLREjM0rLNdyF5WNB8PMJuQPlxWZ+NnOAb 463l3iBrFzdDhYNfM1tQzTnkYVtuS4J3domqcCJem7h4VdMb1wsPhuOrhx1KwrQlEMuQ nBHg== 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=AQfI9itT56aGkQXPmrJoqcBSs6MMztV/FP9e3fo34YE=; b=xmm+71293m0HwsD8q0YP9RBQv5gWq6tl3cP52gfwpTgnwudMDAyhYnBa8zvXKkWodn YefkjlVTEoe/MSMKFJfEBGZcoqBLiXsIevorx15YmWuCSg8kVPL5cnbhJxSDcishK52O S93p9fl19U+o2Xbnzgz0tunXEknHkYey/sQE5MJY7hVkRhcaKmt4w2zcPLOM7AteQl8c JqpzXPqjlWH7xqq4I2txY3CPmolfmmCgq5spFL2XKjfADi7kG9OPh4ebAJ8LYyuDGvl1 JSVn9cOSVkTD9ZluXg6yE4pQBpKvwD+YdV4F9Wv2Vszm954VpgVC3iRzHRgk7rAp5Bnm 1Xrg== X-Gm-Message-State: ANoB5pl9/df1rU/Slv7DriMDnzy4g5mecFYaTF2lv0K//x30pC0u/9DJ WuxKji7mF6q8Q4JhEHAiN4bsnneB5cOX+Z1c232MVA== X-Received: by 2002:a81:9b83:0:b0:381:2226:74ff with SMTP id s125-20020a819b83000000b00381222674ffmr56493985ywg.102.1669784545693; Tue, 29 Nov 2022 21:02:25 -0800 (PST) MIME-Version: 1.0 References: <41eda0ea-0ed4-1ffb-5520-06fda08e5d38@huawei.com> <07a7491e-f391-a9b2-047e-cab5f23decc5@huawei.com> <59fc54b7-c276-2918-6741-804634337881@huaweicloud.com> <541aa740-dcf3-35f5-9f9b-e411978eaa06@redhat.com> <23b5de45-1a11-b5c9-d0d3-4dbca0b7661e@huaweicloud.com> <8d424223-1da6-60bf-dd2c-cd2fe6d263fe@huaweicloud.com> In-Reply-To: <8d424223-1da6-60bf-dd2c-cd2fe6d263fe@huaweicloud.com> From: Hao Luo Date: Tue, 29 Nov 2022 21:02:11 -0800 Message-ID: Subject: Re: [net-next] bpf: avoid hashtab deadlock with try_lock To: Hou Tao Cc: Tonghao Zhang , Waiman Long , Peter Zijlstra , Ingo Molnar , Will Deacon , netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Jiri Olsa , bpf , "houtao1@huawei.com" , LKML , Boqun Feng 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, Nov 29, 2022 at 8:13 PM Hou Tao wrote: > > On 11/30/2022 10:47 AM, Tonghao Zhang wrote: <...> > > if (in_nmi()) { > > if (!raw_spin_trylock_irqsave(&b->raw_lock, flags)) > > return -EBUSY; > > The only purpose of trylock here is to make lockdep happy and it may lead to > unnecessary -EBUSY error for htab operations in NMI context. I still prefer add > a virtual lock-class for map_locked to fix the lockdep warning. So could you use > separated patches to fix the potential dead-lock and the lockdep warning ? It > will be better you can also add a bpf selftests for deadlock problem as said before. > Agree with Tao here. Tonghao, could you send another version which: - separates the fix to deadlock and the fix to lockdep warning - includes a bpf selftest to verify the fix to deadlock - with bpf-specific tag: [PATCH bpf-next] There are multiple ideas on the fly in this thread, it's easy to lose track of what has been proposed and what change you intend to make. Thanks, Hao