Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1151352lqd; Thu, 25 Apr 2024 07:24:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRde4SpA3Ejwgwk9lhBN25ptPL+d3jnQqCNl2G360QPJ7Mn9HaFjX1gMpj9hDuHYoZhUHYBjbHnaqjZwkvedFcJt6tvccfpcoEuR4/ug== X-Google-Smtp-Source: AGHT+IHr83uEcJIRgtj3M0u3JUqSkKUTpWmanHAbycK7GI4smXTZ2bhvAwPwZy3ymU05IyXqjJBi X-Received: by 2002:a05:6a00:2e22:b0:6ed:1c7:8c65 with SMTP id fc34-20020a056a002e2200b006ed01c78c65mr6582393pfb.10.1714055048484; Thu, 25 Apr 2024 07:24:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714055048; cv=pass; d=google.com; s=arc-20160816; b=BDfhIytzkFnLNkozkD9sc02qOhHqZotRvDE7pVg0MuNGLudss+JuPVx2TukiLlPSYC /hHEskLTMd1ZsQSof3vrDtzQrAs5vANvCi/kEmcI6UB5jFM+dr6oteRP+mSaFvNLJf8i +kuc17r8XDP2ykNmeJs0UexbE9Twg5ADM/raic+w3KqxuXDCJiWO+8J9vIe/6dEnxmld frCtE9UDmXpY9L6h/Y+7qkkYiVHxJ2yPY4I7MIGvrzOQnsiQwEt5vwcSu2OYstF5cRKr Iw7cYWnolxHfHS9T1WG9VndaJiygPXCq82G10Sc4/g+CJQDqZat8/MJQE7WpgYxvHKeK H6bQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qStH8dSNcDcItb1wA2JtX3YjxyreJTEee2fjqsXU5t0=; fh=ADq4/vAoeX0/JnXrYGTC4H2FfACa/MOOjz4m6LGat6k=; b=UlXusVe7+aEVMAi6V64y7aosXW+gE8RZSQxN1YIeL8xF4dloMOcTsYbY+Qfo7xgQe7 w7CZyOW0FBMmkeLb78wOT0lY6GPDwPEUUXFuTttwfeDJxOh8Rcb5Lt8CJtnuWPeThWue hfOq8pzYNFXjf3K16+OYBnwD3HiO0u7JGtA8+F0opRKKgHOd2CgiXEtBWEW5I6aLn2A2 zrIlszUGu6/3Qv9kmPgv1M7i6/QLUBZvNG1Wh5SM1RoFIzr6cBKoAk92jId7C685f1lD wF1kfs/WPgaXi93z9PuDpHtIxDfP2zNGPpUUy0t7JFLEQ+UKlMByhSsTmlqZjNya+jft J4lQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TF+96Ggf; 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-158695-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158695-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 n13-20020aa7984d000000b006ecfa4f8fd3si13132158pfq.272.2024.04.25.07.24.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 07:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158695-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=TF+96Ggf; 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-158695-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158695-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 423D928207E for ; Thu, 25 Apr 2024 14:23:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93A6A14AD14; Thu, 25 Apr 2024 14:19:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TF+96Ggf" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 55AD4152166; Thu, 25 Apr 2024 14:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714054773; cv=none; b=axgAZc+7ehqdCq8/qupa8LpKOWekW6CpBjbCjwmm7vMVKgiQ12UuDuZwcCcT6eamEapE0EjmEn8XhJsOG2WR04YYpRQJx9/LB26KCRcIHDG3wJYQ752LA+BqZiwr63jQuvKSbjCZYHfT8wJ93hCfZmm2ftd7YOisBcQ+05HStM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714054773; c=relaxed/simple; bh=5dPWx/XCuPpHn/JbswVAX4unB6CSgL3H/O4srtepiqI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DmZTnA4PmGv1tfvnjEYQNm85cV512pNSv05kfMO4BESlNzIt4QYyc+fHbzdPBpYA5IvHIz9xOUeWhE5krBGNvyQ1DP3j3s3gTdQX9wy1J5jm/l+6bRhPWc8xrelKlMo0zItm+cNuHV3S867kdJNwDJugM6OuyNCs2Sor40OD3p8= 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=TF+96Ggf; arc=none smtp.client-ip=209.85.214.182 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-pl1-f182.google.com with SMTP id d9443c01a7336-1e7af7eb4ccso508015ad.1; Thu, 25 Apr 2024 07:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714054770; x=1714659570; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qStH8dSNcDcItb1wA2JtX3YjxyreJTEee2fjqsXU5t0=; b=TF+96Ggfs/nQLY9BFcdcFWvzS2g2h6VfGzgiD0hbPKVxGLteihV4N0rUrvV1QUYM7U Ro13DP7DglIANAUQ2KzLYhMFzQtSFJ5ejvi48XbIZtAtTajvBjwG37Kv3fPvQHCT3HgC H0xI9Fnambpq0q8C8Akcr7VVB9VPXOw71p5M17n85Xtx5y1nyGSyKU79sT2d4hMv/Wj3 2ZS6YMIR06ExCGjF7ym+QU5t+hbEe8mUHoPzWMJ8poi75N3WgVMwjhXtx8OyBNhIzkQW nnbQrn2oumZARraU2w/9YOfKMef3o42ZFf9PPKGHG9tm6Nojd8jFiecLm1MeKUhf0Irx pxjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714054770; x=1714659570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qStH8dSNcDcItb1wA2JtX3YjxyreJTEee2fjqsXU5t0=; b=XCf9PPsBxKRxzjzUxK0uU7AHjKITVUqmrSgN4nQjQaSsB3cZU4evVnocvf7ZCfbhRy rStSBO7tVRjJpFyKVwwEPwL0EndfcHvoRvasLatv3IHXFNiU2Q4ZM7TpNF1K5GKVAG4m j/rQZvq2P1viyesATX/tkL2lXr0XmQIxf4OsEBCHHkYJMfywGp8fgXK/FXav/JTkDMti U+WUdAVTwfSL+maTkco1giXpZL1WRcItJDjpvadU1iuuZpQnw+nfX7TgFsrmCfiUG4Yh OXKCFUVyq8KRpJPHOt20HqpLVyfoq1YCT7YufdlnCLBtg/Y01eXSd0JglZNaF5poRZzu awiA== X-Forwarded-Encrypted: i=1; AJvYcCUAPnJduhCnUhalWMPUQ67l1ofpeOhf2kebRRPCGuIewaXnuvnBB3aAMiOyLyApK5zmvgqWW2AQPfyKlboHAmoT/E5E96vKEqV6ZoZyQquS3UhvWwI9Q+mq/+eYJ3sPmkxjkP+VeHD4F7JDAaPwIYZJ0xk/HIc2Vvre6RnY7CB1I84OFnMFEL8cRAcrBrPdyeBAAzn5Kvqqi3T+caauNc/+X1A1NEXWFH1gtYPU X-Gm-Message-State: AOJu0YxZlXqcsaNeJ7ZEfbbXmX0oi2/WStLmxOUrAAnA9ojhkFT/FSMD Il5cxsqgNQJn7VI6e9/7t6aBcAtwwSApC/SxSCSSFA3GVampHvig X-Received: by 2002:a05:6a00:718b:b0:6ea:df65:ff80 with SMTP id li11-20020a056a00718b00b006eadf65ff80mr6441795pfb.3.1714054770223; Thu, 25 Apr 2024 07:19:30 -0700 (PDT) Received: from visitorckw-System-Product-Name.. ([140.113.216.168]) by smtp.gmail.com with ESMTPSA id go20-20020a056a003b1400b006e6233563cesm13162397pfb.218.2024.04.25.07.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 07:19:29 -0700 (PDT) From: Kuan-Wei Chiu To: 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 Cc: bfoster@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, jserv@ccns.ncku.edu.tw, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-bcachefs@vger.kernel.org, linux-perf-users@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH v4 12/16] lib min_heap: Rename min_heapify() to min_heap_sift_down() Date: Thu, 25 Apr 2024 22:18:22 +0800 Message-Id: <20240425141826.840077-13-visitorckw@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425141826.840077-1-visitorckw@gmail.com> References: <20240425141826.840077-1-visitorckw@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit After adding min_heap_sift_up(), the naming convention has been adjusted to maintain consistency with the min_heap_sift_up(). Consequently, min_heapify() has been renamed to min_heap_sift_down(). Link: https://lkml.kernel.org/CAP-5=fVcBAxt8Mw72=NCJPRJfjDaJcqk4rjbadgouAEAHz_q1A@mail.gmail.com Signed-off-by: Kuan-Wei Chiu Reviewed-by: Ian Rogers --- drivers/md/dm-vdo/repair.c | 2 +- include/linux/min_heap.h | 14 +++++++------- kernel/events/core.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm-vdo/repair.c b/drivers/md/dm-vdo/repair.c index c1ed3ae823bf..941ac9eda8ca 100644 --- a/drivers/md/dm-vdo/repair.c +++ b/drivers/md/dm-vdo/repair.c @@ -183,7 +183,7 @@ static struct numbered_block_mapping *sort_next_heap_element(struct repair_compl */ last = &repair->entries[--heap->nr]; swap_mappings(heap->data, last, NULL); - min_heapify(heap, 0, &repair_min_heap, NULL); + min_heap_sift_down(heap, 0, &repair_min_heap, NULL); return last; } diff --git a/include/linux/min_heap.h b/include/linux/min_heap.h index 2d080f85ad0d..f907c694e852 100644 --- a/include/linux/min_heap.h +++ b/include/linux/min_heap.h @@ -75,7 +75,7 @@ bool __min_heap_full(min_heap_char *heap) /* Sift the element at pos down the heap. */ static __always_inline -void __min_heapify(min_heap_char *heap, int pos, size_t elem_size, +void __min_heap_sift_down(min_heap_char *heap, int pos, size_t elem_size, const struct min_heap_callbacks *func, void *args) { void *left, *right; @@ -108,8 +108,8 @@ void __min_heapify(min_heap_char *heap, int pos, size_t elem_size, } } -#define min_heapify(_heap, _pos, _func, _args) \ - __min_heapify((min_heap_char *)_heap, _pos, __minheap_obj_size(_heap), _func, _args) +#define min_heap_sift_down(_heap, _pos, _func, _args) \ + __min_heap_sift_down((min_heap_char *)_heap, _pos, __minheap_obj_size(_heap), _func, _args) /* Sift up ith element from the heap, O(log2(nr)). */ static __always_inline @@ -139,7 +139,7 @@ void __min_heapify_all(min_heap_char *heap, size_t elem_size, int i; for (i = heap->nr / 2 - 1; i >= 0; i--) - __min_heapify(heap, i, elem_size, func, args); + __min_heap_sift_down(heap, i, elem_size, func, args); } #define min_heapify_all(_heap, _func, _args) \ @@ -158,7 +158,7 @@ bool __min_heap_pop(min_heap_char *heap, size_t elem_size, /* Place last element at the root (position 0) and then sift down. */ heap->nr--; memcpy(data, data + (heap->nr * elem_size), elem_size); - __min_heapify(heap, 0, elem_size, func, args); + __min_heap_sift_down(heap, 0, elem_size, func, args); return true; } @@ -178,7 +178,7 @@ void __min_heap_pop_push(min_heap_char *heap, void *args) { memcpy(heap->data, element, elem_size); - __min_heapify(heap, 0, elem_size, func, args); + __min_heap_sift_down(heap, 0, elem_size, func, args); } #define min_heap_pop_push(_heap, _element, _func, _args) \ @@ -232,7 +232,7 @@ bool __min_heap_del(min_heap_char *heap, size_t elem_size, size_t idx, return true; func->swp(data + (idx * elem_size), data + (heap->nr * elem_size), args); __min_heap_sift_up(heap, elem_size, idx, func, args); - __min_heapify(heap, idx, elem_size, func, args); + __min_heap_sift_down(heap, idx, elem_size, func, args); return true; } diff --git a/kernel/events/core.c b/kernel/events/core.c index dfd7b5748cbb..82f329c8caea 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3792,7 +3792,7 @@ static noinline int visit_groups_merge(struct perf_event_context *ctx, *evt = perf_event_groups_next(*evt, pmu); if (*evt) - min_heapify(&event_heap, 0, &perf_min_heap, NULL); + min_heap_sift_down(&event_heap, 0, &perf_min_heap, NULL); else min_heap_pop(&event_heap, &perf_min_heap, NULL); } -- 2.34.1