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 6B67BC04FF8 for ; Tue, 23 Apr 2024 04:56:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC9DF6B00B0; Tue, 23 Apr 2024 00:56:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A74136B00B2; Tue, 23 Apr 2024 00:56:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9151C6B00B1; Tue, 23 Apr 2024 00:56:02 -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 6D4996B00AE for ; Tue, 23 Apr 2024 00:56:02 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DAA5C40E0E for ; Tue, 23 Apr 2024 04:56:01 +0000 (UTC) X-FDA: 82039584522.20.AB9A2E2 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf12.hostedemail.com (Postfix) with ESMTP id D6E6840012 for ; Tue, 23 Apr 2024 04:55:59 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Az2m8N3A; dmarc=pass (policy=quarantine) header.from=oracle.com; spf=pass (imf12.hostedemail.com: domain of jianfeng.w.wang@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jianfeng.w.wang@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713848160; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=rewzmuW0zEogE99rkSfOdMtLkSPgWb7owCSbGeAyZ00=; b=EwoVF66E4CBSwLaOfv+H2pvW6utRaShkQvmjWXvOKxcuSrJ9N8e/eIjDtX/4hDUYo31TRf YwwfAiigVYgc/42lp6q55sLh+NKOOLSpZhEdrO062C5aPsHJanH7eX2fcp+DAw/4GAMmKi FZ0og6uFwtgC6WPokeRFF1jZli7/Vbs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Az2m8N3A; dmarc=pass (policy=quarantine) header.from=oracle.com; spf=pass (imf12.hostedemail.com: domain of jianfeng.w.wang@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=jianfeng.w.wang@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713848160; a=rsa-sha256; cv=none; b=xtzYHJQI96EpLDbBF+tLQOse9G6mitYa19hUZynGQ2KQrb6/Q8hpo3Cp6k/1/u10Ejtv0c KqaAM1XuWSX7oJajlA/IkKRsEowQpQ27stim91XeVpBFbzKdZZitNM7BbhpE3BRiBoWU5w MejEJ+LPicu335dkbin3aiYqhJbOgGU= Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43N4j5ws026505; Tue, 23 Apr 2024 04:55:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=rewzmuW0zEogE99rkSfOdMtLkSPgWb7owCSbGeAyZ00=; b=Az2m8N3AhGLTOKeRXI7bYaSCMhhb7n22T5HJrSy7hByttOJRW9QmqlgFsROl8J/CdD1S yOxsbbcnC7EjngRoSXQCcdf17a72pbHcguuEYBF8dZOA8bTVbwxD6GYUHrjpPSdguJ1A cYrz/0Pwi5FDHOdSw1F6+mC23RnL9xujiH1jIRu3Es1lsVrGxFqVBe97N6rdVqmQnq/s 0x/xoTtiKAjxvBWaJSA5J30B/fmoeyF4sYWKysp2+nbpb2bH/MOot7AY4VfePNmXfPb1 ax1AAFIhO8suJiGbTTX8yYaYlbKYhZoqyAZ1oBIWicXqzLMP198LNgY5VAcZfuMMh9hJ cw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xm5kbmc81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 23 Apr 2024 04:55:56 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43N2KJdC033765; Tue, 23 Apr 2024 04:55:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xm456n1b6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 23 Apr 2024 04:55:55 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43N4tt9E007016; Tue, 23 Apr 2024 04:55:55 GMT Received: from jfwang-mac.us.oracle.com (dhcp-10-65-141-153.vpn.oracle.com [10.65.141.153]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3xm456n1ar-1; Tue, 23 Apr 2024 04:55:54 +0000 From: Jianfeng Wang To: linux-mm@kvack.org Cc: vbabka@suse.cz, cl@linux.com, rientjes@google.com, akpm@linux-foundation.org, jianfeng.w.wang@oracle.com Subject: [PATCH v4 0/2] slub: introduce count_partial_free_approx() Date: Mon, 22 Apr 2024 21:55:52 -0700 Message-ID: <20240423045554.15045-1-jianfeng.w.wang@oracle.com> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-23_02,2024-04-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404230013 X-Proofpoint-GUID: OnSyohPFePZvr9zGa1VnNdv2eUIWFFIB X-Proofpoint-ORIG-GUID: OnSyohPFePZvr9zGa1VnNdv2eUIWFFIB X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: D6E6840012 X-Stat-Signature: xzhfrf7wj9df3hmt9jhjwmg97xupjuso X-HE-Tag: 1713848159-88262 X-HE-Meta: U2FsdGVkX19cL91bJzfDdCusOgsV+ftY1v8l//PJmpzUZ1FhFQ5F4Saj0YobSlU7R+CwgTGH5D0+MuUzdIL6XKLbdAw3egWW9ZUyIlEoabULhphStB0PDQVE6IbG6WCe/r9pcsr3syOA1R36UInvieGBOh3S3hoT+OuoUueN2o0eN0jGgxjB4/Xep6oeBa3n+z84ytnbYyhQ+M0o3VMbeeuA72EeLl/pBUf+4OF3BXY4SIxvV+2iKcoSaaghwFUEy3u5I9+jsQ1XV2LrncGrrhBfXPMmT4/XTZWvnKeeV5TB6WPh+iYEEuG77bOYPCwVymve+EaH6cNtdHH1CF2mAHXUrCuzXTKcZdWy87Qkk6TlZryxOJ2I2SiUDJnnUwBoYk7BzvVXSX3fSb/AEB7MzyzKRvWNVlQI5GI1HhXk3BsioqVEHATOO6s96CNGzusyQ9+7bCaWgnL1f4mFLppdgRXvQk77BLny7eazdLHunomyzS0TH1CTeP2FhBCHyimd87i92ebg4I6ZrQwoiP/egdPvkHIHqHKKCTClse7jRWVNzw8ZreOKPYFzsjlwOacdzoPF2J78zuhGnngoIzxrkfGGK0GcMgXQrdUUUhNpPdR2ZBqrlahd5DYqTph4nSUbrhc+DfCmt/sNep1T1ASITp72VcSJu/+5uAlh8VS6m1ZL1E6y1ukgnzNigBRgqIPGrG8a5Bn82dSVD6/osney5Lxs0hqalGqnTETuaEtwF/ucdsGjGO6Jy9eoqC9QTCZuPCwutfRBKnNEqDIWnJbY+G4vNsk5+a8/v8ocvb6OqIx7Kang8z644WnlLneVvetLV0iL6KtGB/YwR+W4Agh83EzId5b7p8C9AM5L6bVBnxRd3chrr2+syCNkZcntCaAyL/wF6fLFq70RgxMBhimPcCTGF6RgKVzdDTYYLNoO7eLT42MubPE2uZ1y0IsOpenop+stzTGUeDD/6XjIXWG o2zuCpal cBVZ80ClJ1KxB/G7zWg/BkdYUzeOeewJF5BM9YPDHhgdEU63A8n7g4+NevQ6tgrrcDTYSxLF/54UBwl7I5GAOizKREQk+5fgKENwRbepEWr+C7QZZTC4xsC9pHnnwC+fkIsFVaTCCoj2v/5WJWrmpQ1SHX2xXRBJA5HvhQ9Khh3ZyGD7mz1tLhj1IoOw/TqP8jlIWRmfST5PNrvfpukdsWp3Ifbvs0I3kQBNa6PFT6bFgxuMbN2y/b/DeuDexlx6olTAIfzDlGe2qGT4NKSw3glgeli0UeDsQL2yggYxVWV4sFhd3pXMcypBIgdJrG3fWQMm+ 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: This patch fixes a known issue in get_slabinfo() which relies on count_partial() to get the exact count of free objects in a kmem_cache_node's partial list. For some slubs, their partial lists can be extremely long. Currently, count_partial() traverses a partial list to get the exact count of objects. This process may take a long time, during which slab allocations are blocked and IRQs are disabled. In production, even NMI watchdog can be triggered due to this matter. The fix is to limit the number of slabs to scan and output an approximated count for a long partial list. The v1 patch counts N slabs from the list's head and then uses it to estimate the total object count in the list. As suggested by Vlastimil, the v2 patch uses an alternative, i.e., counting N/2 from the list's head and tail, produces a more accurate approximation after the partial list is sorted by kmem_cache_shrink(). In the latest version, the implementation is moved to a new function count_partial_free_approx() under CONFIG_SLUB_DEBUG. count_partial() is still used in sysfs. --- Changes since v3 [3] - Place count_partial_free_approx() under CONFIG_SLUB_DEBUG only Changes since v2 [2] - Introduce count_partial_free_approx() and keep count_partial() - Use count_partial_free_approx() in get_slabinfo() and slab_out_of_memory() Changes since v1 [1] - Update the approximation method by counting from the list's head and tail - Cap the approximation by the total object count - Update the commit message to add benchmark results and explain the choice [1] https://lore.kernel.org/linux-mm/20240411164023.99368-1-jianfeng.w.wang@oracle.com/ [2] https://lore.kernel.org/linux-mm/20240417185938.5237-2-jianfeng.w.wang@oracle.com/ [3] https://lore.kernel.org/linux-mm/20240419175611.47413-1-jianfeng.w.wang@oracle.com/ Thanks, --Jianfeng Jianfeng Wang (2): slub: introduce count_partial_free_approx() slub: use count_partial_free_approx() in slab_out_of_memory() mm/slub.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) -- 2.42.1