From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E0E6C4345F for ; Thu, 11 Apr 2024 17:02:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32CC66B0087; Thu, 11 Apr 2024 13:02:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DCB86B00A0; Thu, 11 Apr 2024 13:02:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CB8A6B00A5; Thu, 11 Apr 2024 13:02:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F23006B0087 for ; Thu, 11 Apr 2024 13:02:28 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 78D96C0C79 for ; Thu, 11 Apr 2024 17:02:28 +0000 (UTC) X-FDA: 81997869576.26.3A7F379 Received: from gentwo.org (gentwo.org [62.72.0.81]) by imf13.hostedemail.com (Postfix) with ESMTP id D692D2001E for ; Thu, 11 Apr 2024 17:02:26 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=linux.com (policy=none); spf=softfail (imf13.hostedemail.com: 62.72.0.81 is neither permitted nor denied by domain of cl@linux.com) smtp.mailfrom=cl@linux.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712854947; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o1h/JDpy29E1Wj4+MMhNI6EuDYWtKslnkBn+Nz+ceeE=; b=o2reuAEMnA4uCJmsSNqmGUhBDms/tS/uNBnyxsi9l5NIZEFN+BRbufNR1dp8BwZKW2O0hz S2CAvI80O/zMAyRDqVlggBNHHGi4KXge8Vj7gZvcI74B7XSjowANxpLsoIEoTgEFkx320j sqSI5ghpzuhGO3iK/ebO+dGIyBaYtEM= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=linux.com (policy=none); spf=softfail (imf13.hostedemail.com: 62.72.0.81 is neither permitted nor denied by domain of cl@linux.com) smtp.mailfrom=cl@linux.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712854947; a=rsa-sha256; cv=none; b=rkLZAC457FdcZvO1fgpeme2Tdr5tTwDQlrQ4Gw9GsS6wN3vaY4pmS9E1Xb25WJjMSphO2m /AqbOuYAhQcy+WMYAJB8jfGCKFannIDxkQWBCNN2OZjjwF3mZ1NNiD/TRfgPkuxn7PdhUv RMVW59bvwtc4UVc5D9qjZ+xUDnTooSY= Received: by gentwo.org (Postfix, from userid 1003) id B958240AFA; Thu, 11 Apr 2024 10:02:25 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id B8AED40A90; Thu, 11 Apr 2024 10:02:25 -0700 (PDT) Date: Thu, 11 Apr 2024 10:02:25 -0700 (PDT) From: "Christoph Lameter (Ampere)" To: Jianfeng Wang cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, junxiao.bi@oracle.com Subject: Re: [PATCH] slub: limit number of slabs to scan in count_partial() In-Reply-To: <20240411164023.99368-1-jianfeng.w.wang@oracle.com> Message-ID: References: <20240411164023.99368-1-jianfeng.w.wang@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Rspamd-Queue-Id: D692D2001E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7aghuyxptaroyaidu4ukd1wtemisu3ke X-HE-Tag: 1712854946-498748 X-HE-Meta: U2FsdGVkX1/dkreSTbHlGVeweJfeKkuv8r/XA+NRcdFIrCCU/NCIVV5v20acQm1OibMHvyrnrGSWFRtdBQ+k3OBVcFO+WPejHHLxGh1gVeKyrc723CEmGHRx7HdouisDTSvkCwEZ3fyKvUJAukVdwCSkZwc/8Osj4yqdOMLdD3XxSvmKcvGgzUrwHSpGwFyqJmdQeHieSyzG3EKH+ScN1I6OMzGjtt32PWXxv0weslHid4dnbWYAmJwTD52J8uDUCi82lLJqDy5/SAKmB1wX1AdrOA2xiDmS9J+4TWXX6ln/TCUPLMAPwxERnools08IbUAcPyyfsTPt/XGnShRFHPMdbjfRoeJ3ZJjwbecgFc0VCm6cCe0p+iavprvEkMztlnnS/zppBwHqxUJxlqgjaSv0pD7B2oacxfVWJ8G5Nxi4Rgicr98ymzmz3SdSAJmXhKF4Zo2XuBP6yStiePmQA3cKldGJuC3XNnYdw+XGP9sQ0IJfu31FKArIiOXuT//VFTNP6E1WtT9KDqm0bqZIpncbKPjs02dNuzrIZUlb5gp8kw2a5bBX4a7YdfouVR+c1LMKo5KWFnaaxHIcR1IZuszxz9myLdnVX+sZin14OLkPhZb9a1WpnWqKEduNmKEPzexNoV7zRA333zncNqUZYAf1vd+FhNVQuvQzJtxMox214LMs2vModtgdEoEohtUMON9J1bbZxO0h8jEJft298VqVQEyy6PlpZ4nqcZ6Xxu7xo2gPsI1LrKJln6s664pBAWEJnHPFcnHCTDqhYw9gtmw2MPXMMTL7ScUWIaN9u5Pnsmea21KP/wK4B7NbehVtsklO6FTpfsVKQcMX1bE4dnyj4i8pDCmWSsna/F3DqLdY5/X5QgSdplCTNX+WwsnZYRVfvSZUnQQd31dS3qfnA1Tb6sfGpOW1nv7k+CluARnvVz3q/MjeG+SPrNHnvPf7I5QzZpxbFC7s3Q+AzVR cZrd7t5t sQcKaos4uEwgMs5QpJNO26f/jX0D9Ey0x7BtuwFtTDG1uh7YfoGZvfVtNdh6J0Uo29f+f+GB7bBuhwYKBAW+uypW+JGIGzNS8ynZtbQv+kEK35IoRW5N8c2OEEYl5MJUsuguoEfYgE8KZjZF86DXFPmnVTOMrqZmK27fm4IHiRstTNVJPQuKddqT8NQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. Can you run some tests showing the difference between the estimation and the real count?