From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) (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 24BCC26E6E1 for ; Mon, 23 Feb 2026 18:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771870192; cv=none; b=FNOMp2S3/cbQRnaMqzPg5zWiExgyb/je75G76SeAFJIuL1uWkWQJWvIbx7Bx0x6VTi9iuW0s6wjizXozJPfMBPCh1/0OII5WMc+0RdFiC2aXRRXqh4ikzgEdCIgCdyOu6WKmFmeAxSaMmRXVb0M6iQxCJeRrAumj6JnhRjDebvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771870192; c=relaxed/simple; bh=na/tbwRSN/OigPDxIRS1cy7OFRsKozjFHxklEBqVDRg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PQmw5IPUvHi+OspwSbSwi6XMc1MH99KhC/2PiE/HTrh4GA/p3c5xBBUEl9Lg2VXyjDgEbucWvLNe8mhKnAxngEu09CFQ2lfr9LwZhmUfrGIA7y8sE2KuBe6M+A500kLn/Nd0GOMjipewW2OyFN07mgyYbeGrwcCPh6ZSzWf8UFo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=eJ6KvF+w; arc=none smtp.client-ip=209.85.128.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="eJ6KvF+w" Received: by mail-wm1-f65.google.com with SMTP id 5b1f17b1804b1-483ad568d68so2639545e9.2 for ; Mon, 23 Feb 2026 10:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771870188; x=1772474988; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=8G05LLid+B1Y6OxsFG39BFRld+8LCwvvG4/myaZjVXo=; b=eJ6KvF+wI5hUEvJS0eamjzoRr8JJTJzpro4/Y4YGppW7oMiGOds020QPmtnrOtOkL2 F4jURF4t9F0Rez0cfDv2mZxt8W6e3fuS23iC4QSLhBhdIUAz/PQNKGUXtBkX7y/iPDDh mpH/tPsg01G+UVFrTvxhaGQdukB+dzEnEgRlYa++wJQTgtr7EXjrLOfd/2dBWNMAgobk td1YNCKrq2Wncryad+1cH3QJl6KzLzsORZVIRq7yrZDMMdCqEJ21GL2SND9gr0WET1KI Uyzl+jLUM0IcqmBcuNyAD9WABgqMFrj8ZcAsVTAKUtbvPE5t4NnwrWbJUpcQ0sdwK51P G/Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771870188; x=1772474988; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8G05LLid+B1Y6OxsFG39BFRld+8LCwvvG4/myaZjVXo=; b=CeFs27/HzmL3AVIjbor1F7MMk/eWuDjdzmj2sVafrcbCZ4OExm25JmPVrE1fNCaqp6 pTubJEQb3Mxk856hGB/uM0b1ZTDT30iElhsYn12DchKffWpY3AG4cnnPXHJqBMJLyWny Cr4Xv4mdbzAWBiChWngq+YVrqgrakApEzkRWbP+vbtpjsioQQA5TMNirzI4mxBgqYPj4 FE/6mqiQWBWyn+K0iKnokwQ2vZ2pGy7axiwsJZptq1jn3YuWbq6Kw2kBP0BeCcmxijWH aExNnJs+lx/PFesdlgu2Tttw4FqlMYigQt63Ks7OSZDBBsRFyBK3z180ftyyKZ9hYlxa ZYTQ== X-Forwarded-Encrypted: i=1; AJvYcCVfDryaFe64e0aBUK7z9Y/nvo3C2jlJbIKDkNLjOoaTbSdd70u13DBPHym/dE24gU59eUI+DsKLduO1wYw=@vger.kernel.org X-Gm-Message-State: AOJu0Yy8xhwoiNT0ArfBGyzYmtbtZio8/5zGvbGuE0bbTl31wcll2ed4 HOedz1cRmNRE6oLxfrJ8g4OwLHQZyArC6Wo65lz4/Q+obo+73csWcr8MDLLLZ9Kjcp0= X-Gm-Gg: AZuq6aJHjBQwSkQpk968Ixx+dYhOVIKyNJ0V2VHVh+hAVDNXtfgBOubTZ6NOLwbWz+d wa+4jFnbyDCLzVzXf5ElD0BeYcdbYIXWVzbT+AOhlPwHeuJN6cYz6Uq+7DdFho73EAGrmVKGEoL V4bxZRpZPBN0qslOIohHp0Y2poDTd0/qZX/Mq742W+pYUsgpz4U4YrsVfHJMIPB3uwHPFSlRF8k 1ZZe24u6OmrF1LdfsKjS+OC4TpN/MtrR5OnHcWbKs671XraTpeNbO1uj7nQkMDB8ntW8aB4LmtB gZs9VI9rq/0AwT/7od3SzyUUrZhX1SwDWdzNebyMZxDK8AOLcq0LZU6T+yOg0p7zXEtUVbdfnS5 10ORBhKpj9PqEkJFKSfCUjGnqJ9+XffKT7aEgMFkrxM4ZJK86bHUdjupddORJCaRo01Dd0jMHSk wTTPDK30zhFmjMiC/nkw== X-Received: by 2002:a05:600c:4e48:b0:47a:94fc:d063 with SMTP id 5b1f17b1804b1-483a95eb348mr98005385e9.1.1771870188427; Mon, 23 Feb 2026 10:09:48 -0800 (PST) Received: from ?IPV6:2001:1a48:8:903::e14? ([2001:1a48:8:903::e14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970bfa015sm20581839f8f.8.2026.02.23.10.09.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Feb 2026 10:09:48 -0800 (PST) Message-ID: <1fd2efef-888b-4d3c-9c72-bdb2d594336f@suse.com> Date: Mon, 23 Feb 2026 19:09:47 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/4] Introduce QPW for per-cpu operations Content-Language: en-US To: Marcelo Tosatti , Michal Hocko Cc: Leonardo Bras , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Thomas Gleixner , Waiman Long , Boqun Feng , Frederic Weisbecker References: <20260206143430.021026873@redhat.com> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/20/26 17:55, Marcelo Tosatti wrote: > > #include > #include > #include > #include > #include > #include > #include > > MODULE_LICENSE("GPL"); > MODULE_AUTHOR("Gemini AI"); > MODULE_DESCRIPTION("A simple kmalloc performance benchmark"); > > static int size = 64; // Default allocation size in bytes > module_param(size, int, 0644); > > static int iterations = 1000000; // Default number of iterations > module_param(iterations, int, 0644); > > static int __init kmalloc_bench_init(void) { > void **ptrs; > cycles_t start, end; > uint64_t total_cycles; > int i; > pr_info("kmalloc_bench: Starting test (size=%d, iterations=%d)\n", size, iterations); > > // Allocate an array to store pointers to avoid immediate kfree-reuse optimization > ptrs = vmalloc(sizeof(void *) * iterations); > if (!ptrs) { > pr_err("kmalloc_bench: Failed to allocate pointer array\n"); > return -ENOMEM; > } > > preempt_disable(); > start = get_cycles(); > > for (i = 0; i < iterations; i++) { > ptrs[i] = kmalloc(size, GFP_ATOMIC); > } > > end = get_cycles(); > > total_cycles = end - start; > preempt_enable(); While preempt_disable() simplifies things, it can misrepresent the cost of preempt_disable() that's part of the locking - that will become nested and then the nested preempt_disable() is typically cheaper, etc. Also the way it kmallocs all iterations and then kfree all iterations may skew the probabilities of fastpaths, cache hotness etc. When introducing sheaves I had a similar microbenchmark, but there was different amounts of inner-loop iteraions, no outer preempt_disable(), and linear vs randomized array. See: https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/linux.git/commit/?h=slub-percpu-sheaves-v6-benchmarking&id=04028eeffba18a4f821a7194bc9d14f7488bd7d9 (at this point the SLUB_HAS_SHEAVES parts should be removed and the kmem_cache_print_stats() stuff also shouldn't be interesting for QPW evaluation). > > pr_info("kmalloc_bench: Total cycles for %d allocs: %llu\n", iterations, total_cycles); > pr_info("kmalloc_bench: Avg cycles per kmalloc: %llu\n", total_cycles / iterations); > > // Cleanup > for (i = 0; i < iterations; i++) { > kfree(ptrs[i]); > } > vfree(ptrs); > > return 0; > } > > static void __exit kmalloc_bench_exit(void) { > pr_info("kmalloc_bench: Module unloaded\n"); > } > >