Received: by 2002:ab2:7988:0:b0:1f4:b336:87c4 with SMTP id g8csp107919lqj; Thu, 11 Apr 2024 11:09:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLwTnNMgni5OLGLyjpXP5B73pFcXmRXU4Q4a5c49VI7q8c1xvgKZguMvjVvZ9tMbM4QuPtgvkxSKnGYWb1rEc4k9FIjSGgJ+0vCuD0sQ== X-Google-Smtp-Source: AGHT+IH/YhvluNGONOuS50C3cZmhpKK2+wASzjRyYhDGvE2Ye9caP7uoqZGyogvSjH0Us+lrmUNE X-Received: by 2002:a19:6a0d:0:b0:515:a417:334 with SMTP id u13-20020a196a0d000000b00515a4170334mr270380lfu.46.1712858949656; Thu, 11 Apr 2024 11:09:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712858949; cv=pass; d=google.com; s=arc-20160816; b=bGk/IBog/9C9tCWvFQCHentDwEOtSFyIh7aWwNHyw62R71Krh7+7RDihUjLVPaGfV/ csqH6g2POqI3nBhexh90sBUSDgAxdRaSQziF2688SLvsAP2Nk4KlmUe6zblmlM24L/qS jv3aDM6M82j/4ZjxPAKUpyZPG7NOUDD+sqWpI3UrRMtd1sE8lZu6+Ypbdr4ol0WJuN9C +Oq8irwy398eKgdPx1koQZ8UtmxjBB84SSw8ZN7Qgb0Q8YxNMc0HM6SWlR70mM+9kOzu 6woWQf4S0QSsbCQHvRoZ15LKvAoXey2Ob/IzRIUMLTreiDc7s1eCvP2br3ZZ5oNo4JWm iajw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:from:date; bh=o1h/JDpy29E1Wj4+MMhNI6EuDYWtKslnkBn+Nz+ceeE=; fh=h+Zf0VsNzIT4Or7lb8yzXVCNCga7opoghKKVRi3J39E=; b=uHJCBKmciLXGXX8X/YityNcyLj7fq4rj6OXp27OFMVmLx7TBmpwoaoIOTTEcwgLS7S M/VEYwENc2cFapWoiFwVt7WL6yR7eH2IilaAm0H+/NeT9QUAWgs5dO/Akld3VUzO3Wfw gHTqRhPTSYHoqkhD6l8WsgwRVaRJK3T9L8/10kptoFBMpHSa/jrNeOK+P1hLUZun1Hpt PqUZ3ZFiFzc/lWpudj3pLI6KiKLFXFE8lk58jWhPMLWnFSqpPPGGU2doHuU2dfPEkyKF qBeMFLeESEC6Ai9J9pQjv7jIuez4fa6WFGfHSFGwAVNN63/QoFVhRoBdsnp3w69wwUGb tOyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-141368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.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 d15-20020a170906174f00b00a51e9bb5ceasi915839eje.53.2024.04.11.11.09.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 11:09:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141368-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-141368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.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 586C11F22C12 for ; Thu, 11 Apr 2024 18:09:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25CC150A72; Thu, 11 Apr 2024 17:02:29 +0000 (UTC) Received: from gentwo.org (gentwo.org [62.72.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7E9B4F890 for ; Thu, 11 Apr 2024 17:02:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.72.0.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712854948; cv=none; b=UaE1yKsrlvLrGvtzOiEuVdzFrnVWvcXGS+FCcbrl9Y7q2DjekWiNpiXmPKE5RqcAs5QU6CoDoD48f4s2GnrIdGluH6c0DIMvct94v27ztsIKTGDV7e23UaRI3RelPO3dGDzCKvGQORCh007Dkmp8y9N5lVNtwU8K0nxZZs/gjlc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712854948; c=relaxed/simple; bh=00DQECQXdaUNwZeH1OIGhM3KW5MBwRDfGE0qR2vQptQ=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=jmYp5LYNHHpo6FrvaVUQfKJ3ZU8E5tlSYCsMqoTq0sAfb+h3Um5q/U6NvCM4KC3B5tJ6P5yE0DYt0FnGR3WP5As/eYA2KNMJxPd6Ds/b6bUOaJFWEgnadVWO0qQTtFJUUdjoK8NTKlF/xqT/SSq/zoID2llD8UB1rTOAD7kQU8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=fail smtp.mailfrom=linux.com; arc=none smtp.client-ip=62.72.0.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed 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?