From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=180.181.231.80 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796359693; b=T4LkiKf7KRO0cEjbLveTPhIGIDfFI/ppHYUxPuKWSe0TTUUJX8M8UXCJrQSI1mSkAfFN P5r9nagEAWDCfVTYJkOiYlyBLBXlLlFdPqQnCwuZxMnPgxPSgUnf38g60dNUkXxm+XZPa oac5GIKvQxnNlvekXcfhmt4fCWCq0hOTtrX2Y7gu3PKQvLTDAQIJ74j3GQGX4qJCcx5n8 BK1vxgIlzI7hyUKuVzXIMavy2cSNWXFa8ETFRoxiCcoZW1jVZCMtu0w7qC6oXEfkQh7us C8NTG0EvFgUzUGPjhzTgkJYrxC2NWOd96CrzRACGf+iz4hwT1HpgE6Tv3KBmt7WNRWg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796359693; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=2RDT15M0ABBla7wj302clmYC3t0qmPlGQsrqIIMv9PA=; b=OHor4ZzN96S69s84rKmHhub5fTiBaFqRHe6YlgF5gg3KZDne2m9S9DO004Carq4gE+h7 syxF6dnpxStM0mhH+vieJfjccvVamV2qe3qmcB3BtrdTtWFRixnYlPtITLB4qzws9woOK EN4TE4TT3/c8sKhJSk5kO+WoD71QtqmQ/qcTlD75TBdguhHsJOeOZO/CzJqvrsyWTFzBZ 0YHq5HWwkV8yx/7Zl6wA2ovGtNAEhUSQlKhiMiaL14bxgYXmTC7ZuExPgvstLZIppYLtB ezIlo904PYdJPeuz9IgnsjQdAMadowk3PFO6N5aE1YBbehzgD8gRCIovjnjGMWTUPWg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gondor.apana.org.au; spf=pass smtp.mailfrom=gondor.apana.org.au; dkim=pass header.d=gondor.apana.org.au header.i=@gondor.apana.org.au header.a=rsa-sha256 header.s=h01 header.b=rzo98lPm; arc=none smtp.remote-ip=180.181.231.80 Received: from abb.hmeau.com (abb.hmeau.com [180.181.231.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BF58606A322; Fri, 4 Dec 2026 04:48:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3BF58606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gondor.apana.org.au header.i=@gondor.apana.org.au header.a=rsa-sha256 header.s=h01 header.b=rzo98lPm DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gondor.apana.org.au; s=h01; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:cc:to:subject:message-id:date: from:content-type:reply-to; bh=2RDT15M0ABBla7wj302clmYC3t0qmPlGQsrqIIMv9PA=; b=rzo98lPmKYA9C85O6vZPLMzKwUyslTOrOD6peuJzge6xYq8eKdhsWEQDExwowyWb3bqbFZ2dfav 5yzQRh3EUZTF3LXxiC2MiHwJhNRTjHF7lNIZqrtoWxaoZStTbUQfvMrmXM6T9f3aU0ecEK2s0CDp/ C5FvAcHL1bDsgqaaS4J4At2f2lBnNYES1OTTvuyPA+3TMBzjVSXvoaf/lzZlIGj7QOPof05w8wM0K iQCw3Vf/XhNzLd4sEcMbZsXwYdHPVVYJhEgbECBR/8lFZ9Oq4EK9vpPAXLvhPCRlnAK7YvalVspLY iZqbkRKYXMy2AHcacAgGGy+XUWrxT9IGMsYA==; Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.100.1 #2 (Debian)) id 1xZLD7-00000005E2u-3e6q; Fri, 04 Dec 2026 12:47:54 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 04 Dec 2026 12:47:53 +0800 Date: Fri, 4 Dec 2026 12:47:53 +0800 From: Herbert Xu To: mt4022@columbia.edu Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Mykyta Yatsenko , Andrew Morton , Shuah Khan , Thomas Graf , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , bpf@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tz2294@columbia.edu Subject: Re: [PATCH bpf v2 1/4] rhashtable: Add trylock_irqsoff for callers that can't spin Message-ID: References: <20261122-bpf-rhtab-irqs-disabled-v2-0-207aedcc2215@columbia.edu> <20261122-bpf-rhtab-irqs-disabled-v2-1-207aedcc2215@columbia.edu> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261122-bpf-rhtab-irqs-disabled-v2-1-207aedcc2215@columbia.edu> On Sun, Nov 22, 2026 at 07:25:12PM -0500, Mani Tofigh via B4 Relay wrote: > From: Mani Tofigh > > A caller with IRQs disabled can run inside a bucket lock's critical > section on its own CPU, e.g., in NMI or in a kprobe on the hash function > that the resize worker calls with the lock held. If it then inserts or > removes a key of that bucket it spins on the bit lock forever. > > Add rhashtable_params.trylock_irqsoff. With it, inserts and removes > called with IRQs disabled only try the bucket lock and return -EBUSY if > it's held. A caller with IRQs enabled can't run inside a locked section > of its own CPU, so it still spins, and so does the resize worker. The > flag is a compile time constant in the fast paths like > insecure_elasticity, so other users don't pay for it. > > On UP without DEBUG_SPINLOCK the lock bit isn't kept, so these callers > always get -EBUSY there. > > Suggested-by: Alexei Starovoitov > Signed-off-by: Mani Tofigh > --- > include/linux/rhashtable-types.h | 3 +++ > include/linux/rhashtable.h | 34 ++++++++++++++++++++++++++++++++-- > lib/rhashtable.c | 3 ++- > 3 files changed, 37 insertions(+), 3 deletions(-) I have to say that this looks horrible. > diff --git a/include/linux/rhashtable-types.h b/include/linux/rhashtable-types.h > index 3576b8f08aff..a5c4e696c193 100644 > --- a/include/linux/rhashtable-types.h > +++ b/include/linux/rhashtable-types.h > @@ -52,6 +52,8 @@ typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg, > * @min_size: Minimum size while shrinking > * @insecure_elasticity: Set to true to disable chain length checks > * @automatic_shrinking: Enable automatic shrinking of tables > + * @trylock_irqsoff: With irqs disabled insert and remove don't spin on > + * the bucket lock and return -EBUSY > * @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash) > * @obj_hashfn: Function to hash object > * @obj_cmpfn: Function to compare key with object > @@ -65,6 +67,7 @@ struct rhashtable_params { > u16 min_size; > bool insecure_elasticity; > bool automatic_shrinking; > + bool trylock_irqsoff; Please call it something more obvious like used_in_nmi. But I have to say that I'd rather draw a line and say that rhashtable should not be used in NMI handlers and if you guys need that please design your own data structure. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt