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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AF9BC3DA78 for ; Sun, 15 Jan 2023 22:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231329AbjAOWwF (ORCPT ); Sun, 15 Jan 2023 17:52:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbjAOWwE (ORCPT ); Sun, 15 Jan 2023 17:52:04 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 114091E9C3 for ; Sun, 15 Jan 2023 14:52:02 -0800 (PST) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1673823121; 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=k+/+Dl/ffhAYQAOWMtWO5yTqV8lc0WJllAA0Smoo7zw=; b=LNtnvL87cLn7kMKovy1vFVRkJ1awBCS8NeAHsj4s6r5DhoOAoEFp+t7WR995e4u+9kWyf2 KGsGTjPMBMPML8VIJ3HeIxhU9ACC+ZMwKYbe5vmYoqPxcVWaJN6p4Ed//D2Wkr6mrLPdJW opdG8BlfCg2GpP3gvoj4BAeeVtam+nQ= Date: Sun, 15 Jan 2023 14:51:47 -0800 MIME-Version: 1.0 Subject: Re: [bpf-next v5 3/3] bpf: hash map, suppress false lockdep warning Content-Language: en-US To: Tonghao Zhang Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Hou Tao , bpf@vger.kernel.org References: <20230111092903.92389-1-tong@infragraf.org> <20230111092903.92389-3-tong@infragraf.org> <7e6d02ea-f9f7-2d09-bf10-ccd41b16a671@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 1/13/23 1:15 AM, Tonghao Zhang wrote: > > >> On Jan 13, 2023, at 9:53 AM, Martin KaFai Lau wrote: >> >> On 1/11/23 1:29 AM, tong@infragraf.org wrote: >>> + /* >>> + * The lock may be taken in both NMI and non-NMI contexts. >>> + * There is a false lockdep warning (inconsistent lock state), >>> + * if lockdep enabled. The potential deadlock happens when the >>> + * lock is contended from the same cpu. map_locked rejects >>> + * concurrent access to the same bucket from the same CPU. >>> + * When the lock is contended from a remote cpu, we would >>> + * like the remote cpu to spin and wait, instead of giving >>> + * up immediately. As this gives better throughput. So replacing >>> + * the current raw_spin_lock_irqsave() with trylock sacrifices >>> + * this performance gain. atomic map_locked is necessary. >>> + * lockdep_off is invoked temporarily to fix the false warning. >>> + */ >>> + lockdep_off(); >>> raw_spin_lock_irqsave(&b->raw_lock, flags); >>> - *pflags = flags; >>> + lockdep_on(); >> >> I am not very sure about the lockdep_off/on. Other than the false warning when using the very same htab map by both NMI and non-NMI context, I think the lockdep will still be useful to catch other potential issues. The commit c50eb518e262 ("bpf: Use separate lockdep class for each hashtab") has already solved this false alarm when NMI happens on one map and non-NMI happens on another map. >> >> Alexei, what do you think? May be only land the patch 1 fix for now. > Hi Martin > Patch 2 is used for patch 1 to test whether there is a deadlock. We should apply this two patches. It is too noisy for test_progs that developers routinely run. Lets continue to explore other ways (or a different test) without this false positive splat. Patch 1 was applied as already mentioned in the earlier reply.