Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp630043lqb; Fri, 24 May 2024 08:32:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVai+puqTCo0Q4BzQnVssss9vt4ZPbU3xM0IddhYO7mWrXX4xtgNDluxOEWrDK/zaS7nIfNRyCpNLUXWEW92yZKBMmf9SkR8Cw5ZqAulg== X-Google-Smtp-Source: AGHT+IGalJw783IDRAIpFY1xAiev1/I/H2R0Aj/zi40D9FAndmrF9AnVaYjLYwkV2/SrhONFryxB X-Received: by 2002:a17:906:2a02:b0:a62:187b:e7f5 with SMTP id a640c23a62f3a-a62651287femr177152466b.57.1716564771908; Fri, 24 May 2024 08:32:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716564771; cv=pass; d=google.com; s=arc-20160816; b=uVu9py7UTpjIq29c1OXsTcX3m19PAmPIPutTqYfld5ekQsyrPJ8WevR/BrmHOPwHj6 n3qfl3yi0TiRrbNU1rhcDvlK+rAkWBEBO9Uz0C7GmTwKaTxBxGb5gl7elEDAIItKMcUg p/NRbY0NHj2CJujKIgglvkc9wY3yT3Jic9NosL2wppyUVcS0b9g/K/m5dqmzW2nKAWLk zdYJsYyFwKL7AX845ACXSL2gFK7fJPs2VNdP6b+nJYyl0qmzVvVMXSbUv2kConASs8f6 HNJJcyfJt7QXCAl15owMz4FBPOoaiSKgT5wTGP9TAHqJM22G4o0gd45TVE34gJ2MHrKY tzjw== 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=L6wGqg1Bkc6VloO/r5wptzdiAzti723DW6TYEbY9ymY=; fh=Rn913PVCeO5EI8rnHIAZib5k9GabE0acwE6+heZizeE=; b=h4m5/15h2iAno53q3jT5Jrwvn8gSkE2yDRLVsA2/iDI7PrsdrNw/BqVDKdQLb8Olbs nxGL1p/7BckrgmcpuFd2IJlF4Wx7sgLezGdCkHsctjxUmW3Hr3mLKHmVePlnE7Owimpf +1Ii7BveGIaxicGxPGbL+pDrV6htvaBK4Hn4HSeNSJY17o+cDz1gSUBYCBfuHHq8eFdw FIBkpqWyG2ZsC7V/jnJcaLN9IKuDnLs7mLOlVRksn0zP+bTMFg7BPLHLEgRlyG4Xbcnv wA3qKRaDMfPBqEtEHOHU2fw/qdJ1jgoyKHV/+pI15PiJPx7Enq/SVTeJCFu1cgVV+xje frNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=R8U3o2Ie; 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-188870-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188870-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 a640c23a62f3a-a626cdd33dcsi93369966b.983.2024.05.24.08.32.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 08:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188870-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=@gmail.com header.s=20230601 header.b=R8U3o2Ie; 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-188870-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188870-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9EB451F20C93 for ; Fri, 24 May 2024 15:32:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BC37130AD3; Fri, 24 May 2024 15:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R8U3o2Ie" Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 31848130ACF; Fri, 24 May 2024 15:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716564643; cv=none; b=QTyx3A7tF571G6aLdTexG5jyCIZTVBUSnzc0Y0Pi8c0QC/XnYbjWpSXKZcD74QDrpmrTl0TivYG/Y8jb85iY8xO56VsjrqUbN/wkrWCq1jlkbRrfOy0P8BEsLmOb/X/BUVW+cfcn66SNN+n8FrwZjOhgXLBaiq3OFlPxSSyd0W0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716564643; c=relaxed/simple; bh=KituFP5FWvyk4tf0TCLoKJP1Ug399E1uez9KXSPSXO0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fsPzdOs8fGcqDSKHm6KZ76HeeBU2cQh9f1tRDPLVZmwfDVIu9yU70w51EanBI7UV3ssmNNe42xppATNFa9f1ORSj/oVOPI0LJ3KzFJuQsPIHgU60wZFYJi/f2n7krMbIhYJbLFoiGJAHcAjEck6yTwPSBFI56d5T2rHJQs+8Hxs= 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=R8U3o2Ie; arc=none smtp.client-ip=209.85.216.49 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-f49.google.com with SMTP id 98e67ed59e1d1-2bf5baa5b76so103306a91.0; Fri, 24 May 2024 08:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716564641; x=1717169441; 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=L6wGqg1Bkc6VloO/r5wptzdiAzti723DW6TYEbY9ymY=; b=R8U3o2IechSXYCc2t9e+2bV7+BR8oV5zWVDFmXgJ2xQQcsFvIX3rOKn8xcnjb1ZLbC yV8joStOtlxdWO5OO4oggyOdVZNqnv/gaQN4hTzmNJpaM91oW6zrDMYjd5x/meT3aEFz wLFBDGE/kwhCqxlW3r4x32KYP/mU7CWQZ2E8E2VePmV1W1VJWm1zuAw6YArPPC/OTzXN QTGmH6vUOKw9EZ6Uj2uG+T6BuRwxBETQ/t5+Z/L1FVc5xWW9Cvc2eMXKBdI4XaqNpjrO UKjoMm+jY3nMhtBxyhEv6xpkUO8Xvgff01UUbsUmKU9DBd9DqThjrzokGfJefEAj+GwT emRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716564641; x=1717169441; 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=L6wGqg1Bkc6VloO/r5wptzdiAzti723DW6TYEbY9ymY=; b=uInm1J4IVwhrwWtifgiQrwq/Lm4uWZ2yccWq/lvZYGgNtKUphh849aLRkU4iYuHa0r 23jy1b0b+vX6Ydr+t3ehIpd/g5XulzNKHG9WT4A0kM82KSmmlfUpjmWyaLk4HpqokYYd L3igPr4UB6jN3U5SV++4ewnBJLll+9HnxXr4KRdComYTHMu4PAvoFILxUSj1UOKrWfBe USx+vj13kFy5Gbv4wOhAw5l7eBQT6ANZDl7esUX/hEZzWYdhbiJAULA9f8fwqSXfm2QH eqy6OUZxgDbyNn5rsT7J86Bzsq9aEhRIJuTdRuJrlqV50yqXmQCnMVhKA8oxh7mcYrs1 MD9w== X-Forwarded-Encrypted: i=1; AJvYcCUMHrrBp4z3C+zwBSqQlsHGEUEnHlATc0MudJPpYei2RlAfEfH5vWFFnEKRXOWGXduV3Sm86xMVxGssAucTDUpbufC1hg8jo9fkM8dyKG4Hyx0S4JSg3wYbZbfSEofLaVUoH/2PqSr6W78lX5GZmRXMB8AUwHDqxTAVp7kCcKbBN8eN7tYjdgmidw7OSi8dqqWlxVBHfBh2FUhrpp0qp1rKY7LnLNsj2/UzJ2En X-Gm-Message-State: AOJu0YwNddzvlX+WNnDGVbGCIjeM4d9XQytQulqPutQgxRB8X/CphG3k 3dRhRcmajeNzqIB+SOiS5FkibQrr6lgh/UdIpDPuQm16U2pxP+HB X-Received: by 2002:a17:90b:24c:b0:2b4:329e:eac5 with SMTP id 98e67ed59e1d1-2bf5f202ac5mr2505228a91.2.1716564641436; Fri, 24 May 2024 08:30:41 -0700 (PDT) Received: from visitorckw-System-Product-Name.. ([140.113.216.168]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2bf5f50d294sm1525556a91.20.2024.05.24.08.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 08:30:41 -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, bagasdotme@gmail.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 v6 07/16] lib min_heap: Add min_heap_full() Date: Fri, 24 May 2024 23:29:49 +0800 Message-Id: <20240524152958.919343-8-visitorckw@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524152958.919343-1-visitorckw@gmail.com> References: <20240524152958.919343-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 Add min_heap_full() which returns a boolean value indicating whether the heap has reached its maximum capacity. Signed-off-by: Kuan-Wei Chiu Reviewed-by: Ian Rogers --- include/linux/min_heap.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/min_heap.h b/include/linux/min_heap.h index d9c4ae7ad0cc..f41898c05f5a 100644 --- a/include/linux/min_heap.h +++ b/include/linux/min_heap.h @@ -63,6 +63,16 @@ void *__min_heap_peek(struct min_heap_char *heap) #define min_heap_peek(_heap) \ (__minheap_cast(_heap) __min_heap_peek((min_heap_char *)_heap)) +/* Check if the heap is full. */ +static __always_inline +bool __min_heap_full(min_heap_char *heap) +{ + return heap->nr == heap->size; +} + +#define min_heap_full(_heap) \ + __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, -- 2.34.1