Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1105921lqt; Tue, 19 Mar 2024 12:51:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/sdDJqC5izUaGvmlXj/aCBxxFzzxoBsC7ndRClwOa2ZrSSyagAzD2mFUY2vZ77OvxFA8Rw52VLRLBB/a3g2mathaDlcvnObQWi3ZPBQ== X-Google-Smtp-Source: AGHT+IFpRbvUD+eaMj56l7tK9pFE3nrkdL/uGB/9GHIHMtCc3JO1RsUWNj6tfB4hjun/tvbEINHJ X-Received: by 2002:a17:906:71d4:b0:a46:ecc1:8a2e with SMTP id i20-20020a17090671d400b00a46ecc18a2emr410155ejk.16.1710877910063; Tue, 19 Mar 2024 12:51:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710877910; cv=pass; d=google.com; s=arc-20160816; b=YAeqhw8YAjobnFmULNgYeFdSbZ0yTsF61FYa5+t1JWgveL/Hf2Os/VpUXYGsM4YlCZ O9omoPOt1yI9UktjDiapMv/jNXwRBL3eG0PL46kWfVqonbEpHk5jD/PcVQIAw26v6oQr s11/1zdotZcahOEOlz88zNOQ6KaG7stv2nBSORokX6nenN88HYmq7Hq+mBu3JJlGVWBy 3hAwVpt/n2pVEhEIrNlKqi6lG+juGVXYOXSSrwpCDUY41xJr0UPKkEeuflK7BEvxrLgw z3zK6NMvFmryQNDWzv/JESgc9j3NIKRi9NlO8HpsOUTXKdPenwZO69Q/IbVTYASrkjzE S45Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=0TkXuhmLGM7c9bdHQNzOA0SGeCtxI5tN/gqKMMP6F0c=; fh=M6nbFBB2P8ddTqMwYn+q9SrTKmfMO2EsraIBdM2JkTw=; b=Gdvlgk0uk8nKD/iUUffSK5xTKx9QCip4oRaQS07OcF4whijC4PHX0L0EH4r21dpwmv IXpYwBfpZdmP9PkKov1te6KQ/wvWwSkXLVwOcdTN3I3lIK5E+jdf7MFEk4EDEkHS47qN GiR9U41AdN7Kqp7Oas68EKbpuclj9yc5+fOjAAlPdQZ3GxX22ph6DVRBfqtWP60DHeFe xZRgzfceigg53bgrQZOuTGxnaBhJ0frFjfHMk+TUcj6ce1XBYqtPijAWwxKG1MmcGAU7 vJ4gib5WGhC0110DWGBqIoX7mIcc9S+fWGifzGpVwzoqnkosrRRqhWHPik8gJOhBw6mE eWqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=j8hm5QRA; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hp12-20020a1709073e0c00b00a46636b0819si6018181ejc.894.2024.03.19.12.51.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 12:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=j8hm5QRA; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C17E11F2234E for ; Tue, 19 Mar 2024 19:51:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A9A53BB25; Tue, 19 Mar 2024 19:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j8hm5QRA" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 EC9E93B28F for ; Tue, 19 Mar 2024 19:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710877899; cv=none; b=H/OJJ2ls+1j1XHWJGyaV8LHfcxr5dwwniY61FgxKfGdmgC7/VW2QOUjkUq6LNXqVRyjbbe8nJ7Zh/pYxm3eUoVehKcMAHSlnRxxHH1RSeTDHLOjeRg++9fLaME0DEBKh1uKJThX6x//MvwVcZd0x+sOkvxWwVzeM10qCGUQ+3B0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710877899; c=relaxed/simple; bh=u5ISTVgLFXBHPytLP7czQVcemEzdgRVw+u5krgsn5QA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=mWUnC9kj1fCGa5FWdxhuThaT23fKsN0xHy46kMTAg0M7cKMte5UcqWvo8EWGHkYBIpUxQ2/bFGmXjb9ihCGqrJgDhwehNCjPCyeF99f5M30ddqM9swsc1Vft0Wbkp8jFT1a33VjBYcQvZsDucGLGKqc3QzZhniyTiINXmPGcdSo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=j8hm5QRA; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1dee917abd5so1355ad.1 for ; Tue, 19 Mar 2024 12:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710877897; x=1711482697; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0TkXuhmLGM7c9bdHQNzOA0SGeCtxI5tN/gqKMMP6F0c=; b=j8hm5QRA91NoXNsZMtjBMmSRGagPsBzX2iJSVImfSyJi1LmFDYrJ5+c1pOezGlbZE0 5/IY6Qfx73bArihTLDmlyihtIXP5CD3WhBdbfMfrjcf6eldPT8LfO+7LRfTEffCdnDbr isJYxwH5tFEaJlMoPvGalXe4zl1CiJoWeSO3zF5X9HAgLqoU0UekFmXDN3wEdIoKGR7Q pVP54A38wvPbEPm74idtfRxoQvqQbPhygeMlkatZmD6Ruho59H0SfwvbDrTo3KDBdIBk Xhsn0hPph7UEm8bhKXirnnKnTc/ahgALYj22WsLRLrzTEeRaam4WRlj5cvpVVBcpajcD X9Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710877897; x=1711482697; h=content-transfer-encoding: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=0TkXuhmLGM7c9bdHQNzOA0SGeCtxI5tN/gqKMMP6F0c=; b=tmAqDrTImJHkufD6Qivc0finJjidD9kGTDFdhW9pAOrzwdewU/9sDGa2tLTxOnmcFP WElFJNLVz6hqNwoWZBoQWOGfEAe0/pSXa667tM14dqd0HahXcwvcwHJOXrr+5n3ccU1v RPTE4KIfnkqhQ+C2DcMLWjzRG1gYvafxz4yPOIvBEATDQ81vr/Qc8VfLxW5P824B/enB HdbKtndFhJCHmBXy3dG0RwfJKQM5Aw2v3Bnieg3HZBtCb7qHmdcqFea4aqzKPh6pBddN 6O4CygI97zg2n70Wb2qiMde3aajmge/dYQYSsICNt2CJOzzeGy9Hef0murnLia22hzG/ 0bBQ== X-Forwarded-Encrypted: i=1; AJvYcCV1U/Rg3R4kX8dat+rZwkNLhrpqJSYIUy4pPq0nxHvmYLGWkL2tc0ZIzWT4Q2nzwmODPf3xfbYFYlBshi8oUgzA9iUBMCQv0OGEkmgr X-Gm-Message-State: AOJu0YwA0Xi/IklaeiZrEUPS4L+TSbCdrcLsZOLUL44VkrJbhxBYWBXy l8t8mth1vf251msVyyWojwwmQRdLH11yKE3wkCqps1YP0GSzO8LHxv0SPeGyd4nXlplQ/QYT50r k367ku51U6gnn72aRCmEYjZzkLgBVAydx2rTc X-Received: by 2002:a17:902:ecc8:b0:1de:ff9f:e760 with SMTP id a8-20020a170902ecc800b001deff9fe760mr68290plh.0.1710877897067; Tue, 19 Mar 2024 12:51:37 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240319180005.246930-1-visitorckw@gmail.com> <20240319180005.246930-6-visitorckw@gmail.com> In-Reply-To: <20240319180005.246930-6-visitorckw@gmail.com> From: Ian Rogers Date: Tue, 19 Mar 2024 12:51:22 -0700 Message-ID: Subject: Re: [PATCH 05/13] lib min_heap: Add min_heap_init() To: Kuan-Wei Chiu Cc: colyli@suse.de, kent.overstreet@linux.dev, msakai@redhat.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, akpm@linux-foundation.org, bfoster@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, adrian.hunter@intel.com, jserv@ccns.ncku.edu.tw, linux-bcache@vger.kernel.org, dm-devel@lists.linux.dev, linux-bcachefs@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 19, 2024 at 11:00=E2=80=AFAM Kuan-Wei Chiu wrote: > > Add min_heap_init() for initializing heap with data, nr, and size. > > Signed-off-by: Kuan-Wei Chiu Should this change update lib/test_min_heap.c to use min_heap_init? Thanks, Ian > --- > include/linux/min_heap.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/include/linux/min_heap.h b/include/linux/min_heap.h > index c3635a7fdb88..ed462f194b88 100644 > --- a/include/linux/min_heap.h > +++ b/include/linux/min_heap.h > @@ -44,6 +44,18 @@ struct min_heap_callbacks { > void (*swp)(void *lhs, void *rhs); > }; > > +/* Initialize a min-heap. */ > +static __always_inline > +void __min_heap_init(struct __min_heap *heap, void *data, int size) > +{ > + heap->data =3D data; > + heap->nr =3D 0; > + heap->size =3D size; > +} > + > +#define min_heap_init(_heap, _data, _size) \ > + __min_heap_init(&(_heap)->heap, _data, _size) > + > /* Sift the element at pos down the heap. */ > static __always_inline > void __min_heapify(struct __min_heap *heap, int pos, size_t elem_size, > -- > 2.34.1 >