Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp808077lqt; Fri, 19 Apr 2024 10:59:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUc/qLc67+G5ommvL1aG2WswltIeERNVtGfS4JnmjUMtH1JoAbpD3R2pglwOjDcW/UO2ZkRz7edEDD/t+6/6Gt1jHceBUDBIRY8chWrfg== X-Google-Smtp-Source: AGHT+IG2zonCw6Y22dW/44Qo/0bL45wSksv2C0B6k4ic0IlfvOGdr+Aw+q6BKopG91kDw3t6Ck2Y X-Received: by 2002:a05:6870:4992:b0:22e:9b70:7942 with SMTP id ho18-20020a056870499200b0022e9b707942mr3630920oab.4.1713549544871; Fri, 19 Apr 2024 10:59:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713549544; cv=pass; d=google.com; s=arc-20160816; b=agwklZvB1dRmBXIsjpoxJLHW2GHSU14U4VOVLNxLPNhfzXMNCO+4cfBMglW+F7cx0H pQrUsTYlYjby/H66bHDAnAmwylxb0p31JpEEyuQcflMHfriAYN3FOYM+v6AYMJEnjU/g IYoVNYh/m18SniDedjHY6m8V3gzpb3dwkXMp+zhlyMX7rUFP5wKuxAKNkmJCGS/53x9i 0/XCQBthiOmtASNABkKXiZ8DBrlIJRGzlDKr0bbk0EzKuKvPnar1zLmnZI7QGQvK2nb6 7aJjoK12Mjami2yeBvWp3T2JFrtGT4U7xMulwav3S8st8ZM0J0QLcFOAdpncFmY/CAJ4 Y6Mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=sEyQAxGxkU6mSg9BlzN0eOIMTIjIcy8X5ZvmftEfrfQ=; fh=4gL08H7c/MJSQj3lJrfjLPtDvYV6YpMbDAVSoe68zts=; b=eUF9u/4CAv9nYzQ/Bx9MQ7SfK0ndemQfc0TTmaHa8WFDKMxuIx5AOCPBsKT7ufGCtY Oq/TuDAGI14+jz5/kBcw9dTJ7GJOe3FNaBypSF8Qr2qBds8YMMYpMaoQU47vVn5Th2RY zCdTRHC/vI6x/0T5yXWWFZuGDirWGrXGXNMqOn0Xk32AhjzzyRffnfQ+iHhv95ZX2E2k PxKOfQGZxFEpjkH5fkcgL1FewgTfjMjeyaxqPRMLj4Mv6e8PvpjW0uOCRW88VVuIQJXY kYog8Y7viEOchb+7FLzM8eQCld8ZNqxkOhIgwLGvs2Y8wKBimCL+LbCAIfPDrAgMkg4a VTug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=IehBl+aA; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-151838-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151838-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oracle.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o6-20020a635d46000000b005d8b7c3a019si3571219pgm.856.2024.04.19.10.59.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:59:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151838-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=IehBl+aA; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-151838-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151838-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oracle.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E73C6B21D17 for ; Fri, 19 Apr 2024 17:56:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62D5F13AD30; Fri, 19 Apr 2024 17:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IehBl+aA" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 24407130E5E for ; Fri, 19 Apr 2024 17:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713549387; cv=none; b=BesMPxqlMAzScRlIZzB18oEzNZujKJ98weUlGXNGiTavmdkUooYl2dHbMBgWW8v7tOSdi9I4QaHkFw5OEHU+dp9uwHKUecGP3mpJbKzYn7IiTaIW5Q4kocvaRE6U/C60Fs3bbNS9Dm5KebOpW/32erGudOnLs/LW8XfkhBi6+Tc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713549387; c=relaxed/simple; bh=EH4oorwZc3OtqHaYGL7XKoQ4ECTvU0y/TOOoMZ+6TZU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FHFy5yT22uYOOkPs2zFWHVjk+EPt0q/voGfKa9+hVLT1TjjzHgR9fqjTaTWunnh7B8o1p45qzZwpT8xSGYyPIDa4PcmZoUDDvZttI68ow/6v8FewdqZ1aiMlVyGLrfnKWrmJ5C7LzwHu2Zku2GRAHomD21hGzExcSgjKJzoFle8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=IehBl+aA; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JGiLv8028465; Fri, 19 Apr 2024 17:56:13 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=sEyQAxGxkU6mSg9BlzN0eOIMTIjIcy8X5ZvmftEfrfQ=; b=IehBl+aAG37co6abmxWdSg1oRCJ9zcSFM7nS3t+jq2Jk/GDd0yiatz7cGZJoIjRtOoye xSnc3s9WwN2D/oHGNjtCJoio4/almODMTEX2qNAiyukL2uut++6TuJRO3DZ6j8q9Z37m 8T3CzUvwnyWpBdwcec4YVP4e70nK73pLUi3zNP3sd6/Le+sMZuE8k4hFO2CotFz5cMSh iQGOMI5EY0KLwlGxw3QKVhvmKK1ECg0mtOYrd8utIsZpjEICrq4PGS2Bnw3gXQfuO9kv WpSWdVu/ZunKGSEKjJnixWIuWjxnuoSS/d7yTDftG7HulXdGpnxSVhTyp5KDAoTKmWhR og== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfgn2wemx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 17:56:12 +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 43JH48SH005568; Fri, 19 Apr 2024 17:56:12 GMT Received: from jfwang-mac.us.oracle.com (dhcp-10-159-230-131.vpn.oracle.com [10.159.230.131]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3xkc7xd76r-1; Fri, 19 Apr 2024 17:56:12 +0000 From: Jianfeng Wang To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: vbabka@suse.cz, cl@linux.com, akpm@linux-foundation.org, penberg@kernel.org, rientjes@google.com Subject: [PATCH v3 0/2] slub: introduce count_partial_free_approx() Date: Fri, 19 Apr 2024 10:56:09 -0700 Message-ID: <20240419175611.47413-1-jianfeng.w.wang@oracle.com> X-Mailer: git-send-email 2.42.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-19_13,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190137 X-Proofpoint-ORIG-GUID: coliv5PNpXCgK6sJJQ9zoeoB9O46W5Nq X-Proofpoint-GUID: coliv5PNpXCgK6sJJQ9zoeoB9O46W5Nq 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 proposed 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 this version, the implementation is moved to a new function count_partial_free_approx(). count_partial() is still used in sysfs for users who still want the exact object count. --- 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/ 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