From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECAA346D08F for ; Tue, 21 Jul 2026 17:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656037; cv=none; b=j3FtZWuxnUf1f0RUCX/3yYYR3Fos2u/y28q+t8xRBurFCxL8ry+miUOevGZ6Tk7iKiBN3WLs6PzYUAOyoq536ck+L23ZPFgzzV6W2GYlnytDwsx6SWmRY6tZjXdKjiA4TYzMwZzev1Q9/dBfDozPzjhWq4QB1vI/mBKdTQKOPqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656037; c=relaxed/simple; bh=tSO5QkK9ksdhObAPKffNDjd8EK/nqu04Y7o97jiDAXA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YsVgbYv7P31aaou51zkmLou7Hdb/EATJSUDsnirJmfC595xQD5sv+hNhNfImbK6rZzJt8sJ55Vs1bkluOVJ+ghIcynhhhi1muIf9yn5wjUJF9g+j1uWZRFhe65lvnEWXR2S6eLlLChP1ARssguUCzC8wAk2KHT6GGhOIQkqAM6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CDjnCw7U; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CDjnCw7U" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-84e0688b7e8so936573b3a.1 for ; Tue, 21 Jul 2026 10:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784656035; x=1785260835; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ayvTAngjPEmJRBduoq3CoFHdx+Q9Hcn+4aPuKdlx+rE=; b=CDjnCw7UTLTL2BcPeYM1ZJEJJcclTiuc5WzhVP5eRjxNKCblpU2qr+IlAMMm5H9nR8 Ntq8ylQSMXlwxz0cf9tw7His3k5ws2GAs+I7AImbFwrePt61sjucQGkQ+iODLCPKYHxo eNJXczI6KK4dUmCirB494+1oenJiTbHID5406tRhfLOqG646uFGZMWDpV5wr9ff6Neh0 N0FXTPWhWVpZPX0dWwp8hpe+3f5tRvNkqVjkPS+EHs4B7iP0qOqC8hF6A5cux7ZTYLAH 9rwA490jrtLoNKv8ADtTbYmuIPNM18ruF/3TOygfYdcoS4S0G+B/a4BhVhUfOBXrHGr0 3gVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784656035; x=1785260835; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ayvTAngjPEmJRBduoq3CoFHdx+Q9Hcn+4aPuKdlx+rE=; b=ZKw7p19Wpq4lspRdOESnXcLMtkckcaoHXOTFsXb5gnKkUpXyE51yi/9BAgQ7ra6gY+ 8McWA10I5ZQRLaOg6RXwP1NfChD5crIs7ckqxJuXls0l2YEEDrGT85mS5HF685RLsdml +rG+Qp8KcgNGym/+0CVOfx//YMJ6bWiPp+7tzq1svlO8pXNWg7TZvR8OKCkXhr4nILiA l0Ev+rmuY52R8U7QFCT1QWrOlBzamQ2ulPJYPwiogruw90441nwnEQf+Xow3REXP50WY 0gaAagNcLnByv/UajtBXnsdhjS0QVLtGKdzNl0YgN1N1GrSMvsl7XfAkjU4Y9RuMy0dR p/iA== X-Forwarded-Encrypted: i=1; AHgh+Roo1sXPOAnpLmqLV4Uke1TI25RtFi7EiBAyRZ+9CzS43z3jNtMGFBQoFMZFxCtf6tXUbcRzSwCKXeUrpPs=@vger.kernel.org X-Gm-Message-State: AOJu0YxYLsGDG/CyikhLz8yoPqTIhYzf456Wq5oxj5EqPFWCYblSxqQO 5ckyvn0ySzS+2aGWRAlp4c7iwbM5ruoKBvcLT+SeeIlai+fJFIVlNw50 X-Gm-Gg: AR+sD13OD4eyHMI6nug2C4V5KIMxJRHF24mkl2T5fjYrrBc1U8ajIL/0aAI7AXWPyrw NBH8LF0o66S+80JCIMp9y9ehQdSJlZoUDvc6tdIAk5Etiv9sC2hSp5lK9uak2vgCkep9BSgLvvf EopRcbsJNSBawNZCM7NphhmNHlFc1WJ5sKbdlIV256chNOrirbegKxK1JSVAKRkM9QFwwFUWpZb QBt8I/kZmY8yKGveCc7D+MibC+hbYI16WYBRbwbRNb0rqBDjsgQruHIs5vOZQE+Vq+/ckz0rNCc 3VBQeB06S7XTYQkJh0D8CRq+HskpcpkJC6PSKol+okTGx0b2EEWxRrH96gldDuGos6clIQB+hdf e6gcv8cR8EcsdyR7KnLbKsmnZopitSNObF5bvU5fOd4vh/6iDJnn5IfhFiddW7/QgJGsL986yQd O94w== X-Received: by 2002:a05:6a00:8886:10b0:848:56ff:6ce4 with SMTP id d2e1a72fcca58-84c2926bf62mr15362957b3a.5.1784656035153; Tue, 21 Jul 2026 10:47:15 -0700 (PDT) Received: from google.com ([118.150.148.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84e17264108sm88794b3a.16.2026.07.21.10.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 10:47:14 -0700 (PDT) Date: Wed, 22 Jul 2026 01:47:05 +0800 From: Kuan-Wei Chiu To: ColtenOuO Cc: Andrew Morton , "open list:MIN HEAP" Subject: Re: [PATCH] lib min_heap: add min_heap_empty()/min_heap_empty_inline() Message-ID: References: <20260721172109.112868-1-jun930436@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260721172109.112868-1-jun930436@gmail.com> On Tue, Jul 21, 2026 at 05:21:08PM +0000, ColtenOuO wrote: > Documentation/core-api/min_heap.rst documents min_heap_empty() and > min_heap_empty_inline() as part of the Min Heap API, but these > functions were never actually implemented. Add them, following the NAK. We generally do not introduce new APIs or helper functions that have no in-tree users. Just clean up the doc to reflect reality, rather than adding unused code. > same pattern as the existing min_heap_full()/min_heap_full_inline(). > > Signed-off-by: ColtenOuO Please use your real name for the Sob tag. Regards, Kuan-Wei > --- > include/linux/min_heap.h | 13 +++++++++++++ > lib/min_heap.c | 6 ++++++ > 2 files changed, 19 insertions(+) > > diff --git a/include/linux/min_heap.h b/include/linux/min_heap.h > index 79ddc0adbf2b..931101c29e1d 100644 > --- a/include/linux/min_heap.h > +++ b/include/linux/min_heap.h > @@ -252,6 +252,16 @@ bool __min_heap_full_inline(min_heap_char *heap) > #define min_heap_full_inline(_heap) \ > __min_heap_full_inline(container_of(&(_heap)->nr, min_heap_char, nr)) > > +/* Check if the heap is empty. */ > +static __always_inline > +bool __min_heap_empty_inline(min_heap_char *heap) > +{ > + return heap->nr == 0; > +} > + > +#define min_heap_empty_inline(_heap) \ > + __min_heap_empty_inline(container_of(&(_heap)->nr, min_heap_char, nr)) > + > /* Sift the element at pos down the heap. */ > static __always_inline > void __min_heap_sift_down_inline(min_heap_char *heap, size_t pos, size_t elem_size, > @@ -431,6 +441,7 @@ bool __min_heap_del_inline(min_heap_char *heap, size_t elem_size, size_t idx, > void __min_heap_init(min_heap_char *heap, void *data, size_t size); > void *__min_heap_peek(struct min_heap_char *heap); > bool __min_heap_full(min_heap_char *heap); > +bool __min_heap_empty(min_heap_char *heap); > void __min_heap_sift_down(min_heap_char *heap, size_t pos, size_t elem_size, > const struct min_heap_callbacks *func, void *args); > void __min_heap_sift_up(min_heap_char *heap, size_t elem_size, size_t idx, > @@ -452,6 +463,8 @@ bool __min_heap_del(min_heap_char *heap, size_t elem_size, size_t idx, > (__minheap_cast(_heap) __min_heap_peek(container_of(&(_heap)->nr, min_heap_char, nr))) > #define min_heap_full(_heap) \ > __min_heap_full(container_of(&(_heap)->nr, min_heap_char, nr)) > +#define min_heap_empty(_heap) \ > + __min_heap_empty(container_of(&(_heap)->nr, min_heap_char, nr)) > #define min_heap_sift_down(_heap, _pos, _func, _args) \ > __min_heap_sift_down(container_of(&(_heap)->nr, min_heap_char, nr), _pos, \ > __minheap_obj_size(_heap), _func, _args) > diff --git a/lib/min_heap.c b/lib/min_heap.c > index 96f01a4c5fb6..9e3978a78a93 100644 > --- a/lib/min_heap.c > +++ b/lib/min_heap.c > @@ -20,6 +20,12 @@ bool __min_heap_full(min_heap_char *heap) > } > EXPORT_SYMBOL(__min_heap_full); > > +bool __min_heap_empty(min_heap_char *heap) > +{ > + return __min_heap_empty_inline(heap); > +} > +EXPORT_SYMBOL(__min_heap_empty); > + > void __min_heap_sift_down(min_heap_char *heap, size_t pos, size_t elem_size, > const struct min_heap_callbacks *func, void *args) > { > -- > 2.43.0 >