Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp209279lqb; Tue, 16 Apr 2024 13:14:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2llnFPdVKLR+r2DL+oyWlzd86bC+V2hTheC6xF9lW0CaGvmXP3wNb10nuaUYJbtQITsnWeZl6NEczcb5e7QH9YAuEmrQxTpyOJJDOxw== X-Google-Smtp-Source: AGHT+IG6BUKiHjqSd7m98gRFPdG1tVVzXDgeae9hWtMAISa6ttdKDe0xM/F6Xa+P7WNCaczKIUWw X-Received: by 2002:a05:622a:60f:b0:434:cebf:54d6 with SMTP id z15-20020a05622a060f00b00434cebf54d6mr15487349qta.8.1713298495257; Tue, 16 Apr 2024 13:14:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713298495; cv=pass; d=google.com; s=arc-20160816; b=sZVV5m0PtddzS9RKhgUeUHrPlAUAZ5YaZDRfZtm+1IZKqg07chIHr4VOw+uz/mQlfv znl+ooM7C6D+hjKToES+RS2al5Wi2OJ+fgEv6/+At5XF9Ycl39fWBpAIhMc2y0aEOT5/ ZWJZpqFzDCQJ4nYgA77hkWO9Os4pwwKKKZew36JFrNz7yuO978F+gdq8d4Yvwg9GO+um shFN6i+X8l6KjcQWvJJ8bD0Rn/OOUUC+/oIQfRmkr7ziEmFzPMPu569n1v7mMERxvU6q 7xh/O8EfC/1WfpGykza0mg7gK9fJvAYD12bueziBqvq/G4+aMt14WoxTK4sa/Hm5At/f n61Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=Z7WiYuxpSuB+TscMuMCpsdNIbU6FTnps0eqdPSfyed0=; fh=65Som6KutjaaTbX15KPf84cRsiOE15Udtd9zIbJNjr0=; b=D7GUzqj7rkxfBwEIUBz5U3Gr9OpWhix/egrGRkBTSot4jSSws5m0bzZw0SxEI3iLST pt2flwuvL5oO5kVctie7/hMdBV2/nBnK32De/qGkUDNPkoK2Br0VR27owc9ykfJljnQH dlhFO8X1/GVzCHJQbOiPq2yx7GBGIE1e+uQtwudHuzOezW89u1KzPsnYUigSrhFMcwAy duI5Js83bYnxyB6O9JQVYZWmyGqWCyXHp/REVaYR/4w1/s3wCWteiI5ExMhLhFZINfkZ S7VqeVQb/HiuljnBUhb8ttReLaaXU9i2iqx7iXik25j2tbtqkTAtzb4D8n2vWCKddb7W +AsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="W8Od4/FB"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=ShsaUQM5; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="W8Od4/FB"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-147500-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147500-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c17-20020a05622a025100b00431817ba3a8si14090288qtx.761.2024.04.16.13.14.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 13:14:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147500-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="W8Od4/FB"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=ShsaUQM5; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="W8Od4/FB"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-147500-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147500-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E99021C21054 for ; Tue, 16 Apr 2024 20:14:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2BE0139D0C; Tue, 16 Apr 2024 20:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="W8Od4/FB"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ShsaUQM5"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="W8Od4/FB"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ShsaUQM5" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 978051384B1 for ; Tue, 16 Apr 2024 20:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713298487; cv=none; b=PSbaKg+8Qik2YLJA29oBR1ceDI/f/wo4zXl6pIEAZdNrdS96JUucuQoKRJq8G7g0lXREO+zIvsDFllxuNPCpp2E5VAtZf2lmFtPBsQRIjww9laC0y+M54L5aHHJYul/wGI+BH39DPwvH/2s2+tjLqWCY4+wcjat9cw7z58Qe/Ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713298487; c=relaxed/simple; bh=2JpaBT5X0yQH1TjHzIqs8rPVdPIWs2SGt+tLfYdx2fo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=r8Wz91ETEJzymdk3hRclTEENKwWgKuUAuyRxAkonHwUr1oAxgfK4RB5luk1MHAoHGBXxWa3EPwN5iC4RKrKzQFyAaNAy6H63940LM7J9uvPKWQd2Bz7mv8DFFx+8072NCdKBWQWsDP2ryMRK/13+hddZ6FtTuuKalqg1fE6L+t0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=W8Od4/FB; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ShsaUQM5; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=W8Od4/FB; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ShsaUQM5; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 61C251F86A; Tue, 16 Apr 2024 20:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1713298482; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=Z7WiYuxpSuB+TscMuMCpsdNIbU6FTnps0eqdPSfyed0=; b=W8Od4/FBPF+F0wX+NA//eNUeut6BjcAACj8bOXavfvnXg3V84S+m5QuGrc/ZlJ2/WQnjjS LVWfL4eaDPUkImukNEwZH9RihRDtWksRP7MnkgrwHDC4/NlzZOIla43d94O66tYWkaSpku HHzh+nHsgPFONIk4+PPmtoREqh+NXsg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1713298482; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=Z7WiYuxpSuB+TscMuMCpsdNIbU6FTnps0eqdPSfyed0=; b=ShsaUQM5oGWb4Y7AjW8nxUzH7WGMt1DBIUgja9uUfgJX4D5AyqS+S/4Vat7VCLuWFVlF5w IrYKccrkxtlbMHDw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="W8Od4/FB"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ShsaUQM5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1713298482; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=Z7WiYuxpSuB+TscMuMCpsdNIbU6FTnps0eqdPSfyed0=; b=W8Od4/FBPF+F0wX+NA//eNUeut6BjcAACj8bOXavfvnXg3V84S+m5QuGrc/ZlJ2/WQnjjS LVWfL4eaDPUkImukNEwZH9RihRDtWksRP7MnkgrwHDC4/NlzZOIla43d94O66tYWkaSpku HHzh+nHsgPFONIk4+PPmtoREqh+NXsg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1713298482; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=Z7WiYuxpSuB+TscMuMCpsdNIbU6FTnps0eqdPSfyed0=; b=ShsaUQM5oGWb4Y7AjW8nxUzH7WGMt1DBIUgja9uUfgJX4D5AyqS+S/4Vat7VCLuWFVlF5w IrYKccrkxtlbMHDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4DBD413931; Tue, 16 Apr 2024 20:14:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id //GmEjLcHmbPZAAAD6G6ig (envelope-from ); Tue, 16 Apr 2024 20:14:42 +0000 Message-ID: <653d0bf6-9acc-4625-a307-af195437e744@suse.cz> Date: Tue, 16 Apr 2024 22:14:42 +0200 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] slub: limit number of slabs to scan in count_partial() To: Jianfeng Wang , "Christoph Lameter (Ampere)" Cc: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , "rientjes@google.com" , "iamjoonsoo.kim@lge.com" , "akpm@linux-foundation.org" , Junxiao Bi References: <20240411164023.99368-1-jianfeng.w.wang@oracle.com> <38ef26aa-169b-48ad-81ad-8378e7a38f25@suse.cz> <1207c5d7-8bb7-4574-b811-0cd5f7eaf33d@suse.cz> <5552D041-8549-4E76-B3EC-03C76C117077@oracle.com> <567ed01c-f0f5-45ee-9711-cc5719ee7666@suse.cz> <91e70916-d86a-450e-8cf7-a083fc25d665@oracle.com> From: Vlastimil Babka Content-Language: en-US Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv BB2T79D4WGdDuVa4eOrQ02TxqGN7G0Biz5ZLRSFzQSQwLn8fbwARAQABzSBWbGFzdGltaWwg QmFia2EgPHZiYWJrYUBzdXNlLmN6PsLBlAQTAQoAPgIbAwULCQgHAwUVCgkICwUWAgMBAAIe AQIXgBYhBKlA1DSZLC6OmRA9UCJPp+fMgqZkBQJkBREIBQkRadznAAoJECJPp+fMgqZkNxIQ ALZRqwdUGzqL2aeSavbum/VF/+td+nZfuH0xeWiO2w8mG0+nPd5j9ujYeHcUP1edE7uQrjOC Gs9sm8+W1xYnbClMJTsXiAV88D2btFUdU1mCXURAL9wWZ8Jsmz5ZH2V6AUszvNezsS/VIT87 AmTtj31TLDGwdxaZTSYLwAOOOtyqafOEq+gJB30RxTRE3h3G1zpO7OM9K6ysLdAlwAGYWgJJ V4JqGsQ/lyEtxxFpUCjb5Pztp7cQxhlkil0oBYHkudiG8j1U3DG8iC6rnB4yJaLphKx57NuQ PIY0Bccg+r9gIQ4XeSK2PQhdXdy3UWBr913ZQ9AI2usid3s5vabo4iBvpJNFLgUmxFnr73SJ KsRh/2OBsg1XXF/wRQGBO9vRuJUAbnaIVcmGOUogdBVS9Sun/Sy4GNA++KtFZK95U7J417/J Hub2xV6Ehc7UGW6fIvIQmzJ3zaTEfuriU1P8ayfddrAgZb25JnOW7L1zdYL8rXiezOyYZ8Fm ZyXjzWdO0RpxcUEp6GsJr11Bc4F3aae9OZtwtLL/jxc7y6pUugB00PodgnQ6CMcfR/HjXlae h2VS3zl9+tQWHu6s1R58t5BuMS2FNA58wU/IazImc/ZQA+slDBfhRDGYlExjg19UXWe/gMcl De3P1kxYPgZdGE2eZpRLIbt+rYnqQKy8UxlszsBNBFsZNTUBCACfQfpSsWJZyi+SHoRdVyX5 J6rI7okc4+b571a7RXD5UhS9dlVRVVAtrU9ANSLqPTQKGVxHrqD39XSw8hxK61pw8p90pg4G /N3iuWEvyt+t0SxDDkClnGsDyRhlUyEWYFEoBrrCizbmahOUwqkJbNMfzj5Y7n7OIJOxNRkB IBOjPdF26dMP69BwePQao1M8Acrrex9sAHYjQGyVmReRjVEtv9iG4DoTsnIR3amKVk6si4Ea X/mrapJqSCcBUVYUFH8M7bsm4CSxier5ofy8jTEa/CfvkqpKThTMCQPNZKY7hke5qEq1CBk2 wxhX48ZrJEFf1v3NuV3OimgsF2odzieNABEBAAHCwXwEGAEKACYCGwwWIQSpQNQ0mSwujpkQ PVAiT6fnzIKmZAUCZAUSmwUJDK5EZgAKCRAiT6fnzIKmZOJGEACOKABgo9wJXsbWhGWYO7mD 8R8mUyJHqbvaz+yTLnvRwfe/VwafFfDMx5GYVYzMY9TWpA8psFTKTUIIQmx2scYsRBUwm5VI EurRWKqENcDRjyo+ol59j0FViYysjQQeobXBDDE31t5SBg++veI6tXfpco/UiKEsDswL1WAr tEAZaruo7254TyH+gydURl2wJuzo/aZ7Y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: <91e70916-d86a-450e-8cf7-a083fc25d665@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [-4.50 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; XM_UA_NO_VERSION(0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_SEVEN(0.00)[9]; FUZZY_BLOCKED(0.00)[rspamd.com]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[oracle.com:email,suse.cz:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 61C251F86A X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Score: -4.50 On 4/16/24 8:58 PM, Jianfeng Wang wrote: > > > On 4/15/24 12:35 AM, Vlastimil Babka wrote: >> On 4/13/24 3:17 AM, Jianfeng Wang wrote: >>> >>>> On Apr 12, 2024, at 1:44 PM, Jianfeng Wang wrote: >>>> >>>> On 4/12/24 1:20 PM, Vlastimil Babka wrote: >>>>> On 4/12/24 7:29 PM, Jianfeng Wang wrote: >>>>>> >>>>>> On 4/12/24 12:48 AM, Vlastimil Babka wrote: >>>>>>> On 4/11/24 7:02 PM, Christoph Lameter (Ampere) wrote: >>>>>>>> On Thu, 11 Apr 2024, Jianfeng Wang wrote: >>>>>>>> >>>>>>>>> So, the fix is to limit the number of slabs to scan in >>>>>>>>> count_partial(), and output an approximated result if the list is too >>>>>>>>> long. Default to 10000 which should be enough for most sane cases. >>>>>>>> >>>>>>>> >>>>>>>> That is a creative approach. The problem though is that objects on the >>>>>>>> partial lists are kind of sorted. The partial slabs with only a few >>>>>>>> objects available are at the start of the list so that allocations cause >>>>>>>> them to be removed from the partial list fast. Full slabs do not need to >>>>>>>> be tracked on any list. >>>>>>>> >>>>>>>> The partial slabs with few objects are put at the end of the partial list >>>>>>>> in the hope that the few objects remaining will also be freed which would >>>>>>>> allow the freeing of the slab folio. >>>>>>>> >>>>>>>> So the object density may be higher at the beginning of the list. >>>>>>>> >>>>>>>> kmem_cache_shrink() will explicitly sort the partial lists to put the >>>>>>>> partial pages in that order. >>>>>>>> >>> >>> Realized that I’d do "echo 1 > /sys/kernel/slab/dentry/shrink” to sort the list explicitly. >>> After that, the numbers become: >>> N = 10000 -> diff = 7.1 % >>> N = 20000 -> diff = 5.7 % >>> N = 25000 -> diff = 5.4 % >>> So, expecting ~5-7% difference after shrinking. >>> >>>>>>>> Can you run some tests showing the difference between the estimation and >>>>>>>> the real count? >>>>>> >>>>>> Yes. >>>>>> On a server with one NUMA node, I create a case that uses many dentry objects. >>>>> >>>>> Could you describe in more detail how do you make dentry cache to grow such >>>>> a large partial slabs list? Thanks. >>>>> >>>> >>>> I utilized the fact that creating a folder will create a new dentry object; >>>> deleting a folder will delete all its sub-folder's dentry objects. >>>> >>>> Then, I started to create N folders, while each folder has M empty sub-folders. >>>> Assuming that these operations would consume a large number of dentry >>>> objects in the sequential order. Their slabs were very likely to be full slabs. >>>> After all folders were created, I deleted a subset of the N folders (i.e., >>>> one out of every two folders). This would create many holes, which turned a >>>> subset of full slabs into partial slabs. >> >> Thanks, right, so that's quite a deterministic way to achieve the long >> partial lists with very close to uniform ratio of free/used, so no wonder >> the resulting accuracy is good and the diff is very small. But in practice >> the workloads that may lead to long lists will not be so uniform. The result >> after shrinking shows what happens if there's bias in which slabs we inspect >> due to the sorting. But still most of the slabs will have the near-uniform >> free/used ratio so the sorting will not do so much difference. But another >> workload might do that. >> >> So what happens if you inspect X slabs from the head and X from the tail as >> I suggested? That should help your test case even after you sort, and also >> should in theory be more accurate even for less uniform workloads. > > Yes, the approach of counting from both directions and then approximating > works better after sorting the partial list. Yeah I think we could go with that approach then. Let's do 5000 from each side. You can check whether n->nr_partial < 10000 and then just scan the whole list in single direction with no approximation, and otherwise 5000 from each side with approximation. I think the code as you show below will scan some slabs in the middle of the list twice if there's between 5000 and 10000 on the list, so checking n->nr_partial would avoid that. Thanks! > Here is what I did. > --- > +static unsigned long count_partial(struct kmem_cache_node *n, > + int (*get_count)(struct slab *)) > +{ > + unsigned long flags; > + unsigned long x = 0; > + unsigned long scanned = 0; > + struct slab *slab; > + > + spin_lock_irqsave(&n->list_lock, flags); > + list_for_each_entry(slab, &n->partial, slab_list) { > + x += get_count(slab); > + if (++scanned > MAX_PARTIAL_TO_SCAN) > + break; > + } > + > + if (scanned > max_partial_to_scan) { > + scanned = 0; > + list_for_each_entry_reverse(slab, &n->partial, slab_list) { > + x += get_count(slab); > + if (++scanned > MAX_PARTIAL_TO_SCAN) { > + /* Approximate total count of objects */ > + x = mult_frac(x, n->nr_partial, scanned * 2); > + x = min(x, node_nr_objs(n)); > + break; > + } > + } > + } > + spin_unlock_irqrestore(&n->list_lock, flags); > + return x; > +} > --- > > Results: > --- > * Pre-shrink: > MAX_SLAB_TO_SCAN | Diff (single-direction) | Diff (double-direction) | > 1000 | 0.43 % | 0.80 % | > 5000 | 0.06 % | 0.16 % | > 10000 | 0.02 % | -0.003 % | > 20000 | 0.009 % | 0.03 % | > > * After-shrink: > MAX_SLAB_TO_SCAN | Diff (single-direction) | Diff (double-direction) | > 1000 | 12.46 % | 3.60 % | > 5000 | 5.38 % | 0.22 % | > 10000 | 4.99 % | -0.06 % | > 20000 | 4.86 % | -0.17 % | > --- > > For |MAX_SLAB_TO_SCAN| >= 5000, count_partial() returns the exact > object count if the length of the partial list is not larger than > |MAX_SLAB_TO_SCAN|. Otherwise, it counts |MAX_SLAB_TO_SCAN| from both > the head and from the tail, and outputs an approximation that shows > <1% difference. > > With a slightly larger limit (like 10000), count_partial() should > produce the exact number for most cases (that won't lead to a > lockup) and avoid lockups with a good estimate.