Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1269732lqt; Tue, 19 Mar 2024 19:57:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1O+5qg+cGBqSpRihGpkqphUrDzxrnA7yNd9qTNW1z8vcaoPSPRvZj/zZoF5p/lIMWBoy+BvU+2WI8UWEtTVu+z6lyso8yZPJ5EO5vwA== X-Google-Smtp-Source: AGHT+IHJphvmqEkYjCde1aBKYHC3egne0nfrZJIZTW97DOgQmvVWqrli/xhrTOzcTsQiySUHztEd X-Received: by 2002:a17:90b:68b:b0:29b:f753:5661 with SMTP id m11-20020a17090b068b00b0029bf7535661mr6406752pjz.13.1710903424760; Tue, 19 Mar 2024 19:57:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710903424; cv=pass; d=google.com; s=arc-20160816; b=zXrdtNQqL9za/kHSYZsFuxtx4Rrvqex2saOSf57N7QAYEcEFlyBAHJn1YfFd58N+rE c2LbCDI9mUwJ79RqBfB/NC/4ca8gcxnhEKRM18yAqSw9saz7xJGaJZCBYHTU/HUHP2Ud QO1uKKsEW2vWt97Z1NjCzCD1qe15mlDZ8TrOLF5BaHom4K/q0NwGm1yJ5LYhOevMJk5L CKBgJJenLwc/Z4uyslO/MVASFlCIJno+Vmpo1r9dg52GIyVdznw0cNDZzucUcQgCb8jK 6vx79ZCI9wGdgQ2PbK6/5idkGYVoraMyKuVNMhiHf4oOB/sBX9LkSu1THGefCYc0L6M4 m/Xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qsOh/COH4UX9LhObfLCurk23uZsxjWsmdSmkDaZcSnQ=; fh=J1J3vBSpqyz1hX0Z6Yog9BiHmCYyPemR2xO8uOr7vQA=; b=K9zyqW7vlv9ZlJU4zYC2xTlMeV6WmcM/7P7pkX8skmQZ2Mqd644xLG7cw9C2RliTJW uViCkSO5wwk//AbnTL9jLd5SoBwQjuxZWia2UgFUucLl+zj4UiYxX6fmuxg1LiUpUJjL FaDPUhYuaKHoNMWcafAVWirph7Io9+ycakLU/+7VH4tDDizrJkc3L89WwUMTUuntYiG+ Otc+3lJvA3J8ucWDxXS7bsmKuxdLxQ5d0Fe5ArToW6JA83o7pGbQuHt98650sq30Cuie cIvYNrst86cyo6WC4CxWhSc38E0JbIC1RuL+ApT/MH2v7kd241HyBYo0eZDlVF0eZxnG cj/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HtWff0Og; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-108400-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108400-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y3-20020a17090a134300b0029bb6ed5c4esi512734pjf.82.2024.03.19.19.57.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 19:57:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108400-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HtWff0Og; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-108400-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108400-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 677112849AC for ; Wed, 20 Mar 2024 02:57:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26BF71119A; Wed, 20 Mar 2024 02:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HtWff0Og" Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 0295AF9E8; Wed, 20 Mar 2024 02:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710903414; cv=none; b=fd5MFW+ztTv5AEnXHmgq+GlrvRJWnDbdRAOm53M8j8+U6Avn15xPnsTq0rHMCvzY1PfCQZxJbU7s0d2PYzien5bK1nk8vWMRHi5wMP0xeo+ns7U89ao/5mDi+EANw26iUIWoceJ0DBzzG+B+GhoXk8KQhSylhcYAL5gbpsf/kUk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710903414; c=relaxed/simple; bh=QB2rQUbSStW7n4EoQ3DbUud+Rx1zHt6q2tLkyIr7z1c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S5OqkoqhekQhd4m6YU2WxuaVtcN6yJiJs9/KSZjP6IDx3xGT9HkHr+7rqKWeWmwtysBrm8PGO+jL3vEw4sLxwEeL1FwyBFER55c9arMuQwZ92iPuO1PCY15hWrimEFrrvJTDFNpnT86xlPV+LJsayoqLasS9oTbQDZYgYwPPaN4= 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=HtWff0Og; arc=none smtp.client-ip=209.85.216.51 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 Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-29c572d4b84so2028260a91.1; Tue, 19 Mar 2024 19:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710903412; x=1711508212; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=qsOh/COH4UX9LhObfLCurk23uZsxjWsmdSmkDaZcSnQ=; b=HtWff0OgxBnv31Tt5r1rFJY9SBLtraXOSTsWdfP7o1lCNZghJBDIh2mhHVRDOXFHXw 6ItZtqrLhXDSXwRHrkF3sQkHBCTUqUNsgkQES8zrPfoW0vqhfUiBPW9g23lOFxazl+/o lL4DesuEa9seYvoGhakW4p1P/xCQJ/NrUTlmj9O03cCm+V8Ge82bGVBtCUj3HM1gz7Hb 9GSR2AkKFfQuD8IJ2X0lvIvlkyFO9k+StKqVr/HGlKID1dnxk3bw/jl2iHTgn3ySsgd7 bVDSR4OKsS7W0ntPwKt6ujBq8WSdueXXvQ01xDPk3Gg2TLzgRSLrtMh7dWPArBxGt03k 31+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710903412; x=1711508212; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qsOh/COH4UX9LhObfLCurk23uZsxjWsmdSmkDaZcSnQ=; b=J2hYYWkBgphE5JeCLz1wnRryWnaX8Ah00hyGz8CBLDyTOx82utaGZ9lJc6gObEG8LN 94KIgpiCegDhDz0FhzJab8rxdjDWPKbRuBtwaPD2cChgemnhUcXNH5UdcZ5z+SMBCeIi bMWio9ojHNE8I7viav/3HcV0cGNPCF+YsLD6m/r0Hj+IY4L2JwHVNUtbMMUPre8IIpue uICLwqvKx7Mm2fYEV4aR9zPxH+zmMx2maoRNAv8Ym1ZQPU7CwSRgVQeiXXbWpUBs/lyy chzYLpbalAD6QKr4CLPWxR9vyXrrzbY8447uKLLM5ec2J8KeDLyrPk4lpd0qvP6pdYrP VJFQ== X-Forwarded-Encrypted: i=1; AJvYcCWetiGOnm224C3f/JLyCFGDimsY3kebhs0BV49L9QJmlHun/q2jM/Jf2aZNyGrvcn+KdPw+SANy4J6EeEkiNZi9Dxg732tVtH1qJSNDtboRo8CpNi+kjF+/bINh4kKbV6TbS/5dxDw+gE08aW3jvZ1reLFRAWaHdZcKmT6YbTpfJ72ZLRrkNzmr3LuhVvDAQcARYyVtHxt4LG1wZqy2oIAwDLlm40aH0K4gwbVM X-Gm-Message-State: AOJu0YyRbw6mKnoftjj6V/Y9ncJdsT/umZsO26J8rHTUA2deYaS2HdCe lXgVr3TGf1Uix1I3X3c+UgdYXhasmbNjNyGyMJ47o+oWG66kyCkQ X-Received: by 2002:a17:90a:bf0b:b0:296:db75:c240 with SMTP id c11-20020a17090abf0b00b00296db75c240mr3863223pjs.1.1710903412309; Tue, 19 Mar 2024 19:56:52 -0700 (PDT) Received: from visitorckw-System-Product-Name ([140.113.216.168]) by smtp.gmail.com with ESMTPSA id m10-20020a17090a7f8a00b0029c13f9bd7fsm330388pjl.34.2024.03.19.19.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 19:56:51 -0700 (PDT) Date: Wed, 20 Mar 2024 10:56:47 +0800 From: Kuan-Wei Chiu To: Ian Rogers 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 Subject: Re: [PATCH 05/13] lib min_heap: Add min_heap_init() Message-ID: References: <20240319180005.246930-1-visitorckw@gmail.com> <20240319180005.246930-6-visitorckw@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Mar 19, 2024 at 12:51:22PM -0700, Ian Rogers wrote: > On Tue, Mar 19, 2024 at 11:00 AM 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? > Sure, will do that in v2. Regards, Kuan-Wei > > > --- > > 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 = data; > > + heap->nr = 0; > > + heap->size = 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 > >