Received: by 2002:ab2:5182:0:b0:1f4:61d5:3ad4 with SMTP id x2csp64834lqi; Fri, 5 Apr 2024 09:50:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJ7mu7uo+MC00ce7Rmr0xP+a4xkTeJH6hxerwjQY8DMPbQhZ1jZ3Tn6kiP8NIyL2u2GU1uNDn07pJt7CjTbV1dnKpPCO4TjneR++k3zQ== X-Google-Smtp-Source: AGHT+IE7MwcotbSaf9jk1pi4V3aMP01Pngu4i7fKoGBk9CTvJg/clpkMGJeg/QFC/nyjCD45D2H5 X-Received: by 2002:a9d:77ca:0:b0:6e8:9145:8d8b with SMTP id w10-20020a9d77ca000000b006e891458d8bmr2055365otl.10.1712335831347; Fri, 05 Apr 2024 09:50:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712335831; cv=pass; d=google.com; s=arc-20160816; b=bPA+4LcQU98Sme5caBShWH+0m5aWjhFEtKGtPneWUgkfmNSwxF/Zi8Na/yRGJ5Exqe bKoABRVPfI/rb3JMqOcHkaEqwWlgwQiJM4Dphp7N6TkKgxZJE39Do06J8i+QJcYQxVp8 JX7xTnoAAMPqljc1mVpIJsb3u045aMksZuhUccHrx0WeVWNbpo95pOWoz/27YruaTHBd mx4hIfKlNpzI03S52LY8mLjvo8DY4OJxQ8fXO98caSs9QkEDThGgbDJR2dgoNehtpzZJ AyoR7EjeJj63J62x+MCsZEf79Ie1LfwpNXg9EkhVYGSAOfyW41J+G6ji1DZtxkZz8sIV QqPg== 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 :dkim-signature; bh=09aWB77GcwTGv7cWV+WUqIpB08zLvcLsBsdJpNtZe5o=; fh=KW0t9gAFzWUgKRZxeUPcFoLEWZE3XAW+Dku7iCx9Zic=; b=Scn9td1XzmSNbohn0TATgLQNYnWG8m6FJ3I8m6ivo9mWrv34GFbBC4LP4/0K5SGunE 06jrulqtZWTCenidmfYZe+cDC1C3v4xt5+ElXy+dgAVC0FJs3Cz28G/UH5s4FIjQVRPp sQ1gR0afxMrFyoKxGRFH/TS7+eTUMlefGxIq1oB/dgwrMV5zYNGRQem4+7xY+3lJnSEU yHWCLA4vrkEB2YjWVkz2grriPhxPsOoiuGSznqenLOTcta9LzTlb/V8t7MECCJgulWYT 4X16dST0nKiz3ycOIP6SiovcftsoFfXO1awKHlpFMOxd9JJEw0a+1lDizlazCQEKlNYH vs4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=neutral (invalid public key) header.i=@gentwo.org header.s=default header.b=piJPZuR3; arc=pass (i=1 spf=pass spfdomain=gentwo.org dmarc=pass fromdomain=gentwo.org); spf=pass (google.com: domain of linux-kernel+bounces-133367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentwo.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n4-20020a05622a11c400b004346859eacfsi566417qtk.473.2024.04.05.09.50.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 09:50:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133367-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=neutral (invalid public key) header.i=@gentwo.org header.s=default header.b=piJPZuR3; arc=pass (i=1 spf=pass spfdomain=gentwo.org dmarc=pass fromdomain=gentwo.org); spf=pass (google.com: domain of linux-kernel+bounces-133367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentwo.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 E97CC1C2135F for ; Fri, 5 Apr 2024 16:50:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2D3E171649; Fri, 5 Apr 2024 16:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=permerror (0-bit key) header.d=gentwo.org header.i=@gentwo.org header.b="piJPZuR3" 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 3176720B0F for ; Fri, 5 Apr 2024 16:50:23 +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=1712335824; cv=none; b=sq8GNA0rdXPBnxdsauMlxwdvSG8t+dzjKjLcgNiTn8OZbVm5ulmSu/sxPqFkrHioWW/XcgaEgJiGnEwp0ebLTPebmsXLXaKhU2hwnZ23M1kLs1QaZkoZCA9eMbmL0YxdROZBT+dZpz7m88pp0VRHOpg34m+rb+jbwny5N6WsoHI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712335824; c=relaxed/simple; bh=jxZRTYp0lYxN1n5vVd2kDP+TuexqmFFWBYOJfm6H/JM=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=FzVbl92QTmLRGYTj63HODUw53JYZ/9MqONoul5mzjer3zYh9o//YKwfIKJlWaWq4nCxUlWeMU/UwWV/CD+N3HwBYQg5ux4fE20ugnSXsb4erHhF/BwkUmtNj9q818Qtg91Cxo12TTQ7u9vgXXIKcPlSIZnLOI3k4eApbI2tYd8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentwo.org; spf=pass smtp.mailfrom=gentwo.org; dkim=permerror (0-bit key) header.d=gentwo.org header.i=@gentwo.org header.b=piJPZuR3; arc=none smtp.client-ip=62.72.0.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gentwo.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gentwo.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.org; s=default; t=1712335822; bh=jxZRTYp0lYxN1n5vVd2kDP+TuexqmFFWBYOJfm6H/JM=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=piJPZuR3WuXyKKeZUkRLm7V4YnJy7TTI73aqrg55gwu5F8ZMU81fXRcoKmHF3X0SV VGSYtgNfOe3zkVV8xWZGcKV94qcmo86MFGAcUJPLFVAb6AeDd6YnHTe+KcYOHuo5Pv Pj5apSkFLc6Z6dAau869/VBp6BNUIu6bj3Wtf4Irr/recf0wwROy2fCMY9Q27AsVwb 0xd7SnavKu4cDKHNUoak54aWjh00XaII1HllAinbWvL5iYcDqQbcpespveTMGcoZP2 NgMyXwLAohbtfj3e17T1vQDJhCp0wgLDuwjuZlqXkGvcnkTuorYcDlCDhriaYOScwn 2e6QfdoToQJBA== Received: by gentwo.org (Postfix, from userid 1003) id 365D540A86; Fri, 5 Apr 2024 09:50:22 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id 3598540A80; Fri, 5 Apr 2024 09:50:22 -0700 (PDT) Date: Fri, 5 Apr 2024 09:50:22 -0700 (PDT) From: "Christoph Lameter (Ampere)" To: Chen Jun cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, xuqiang36@huawei.com, wangkefeng.wang@huawei.com Subject: Re: [PATCH v2] mm/slub: Reduce memory consumption in extreme scenarios In-Reply-To: <20240330082335.29710-1-chenjun102@huawei.com> Message-ID: <0a59e5a1-1961-5eb2-2eb0-a930006e3f80@gentwo.org> References: <20240330082335.29710-1-chenjun102@huawei.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 Sat, 30 Mar 2024, Chen Jun wrote: > When kmalloc_node() is called without __GFP_THISNODE and the target node > lacks sufficient memory, SLUB allocates a folio from a different node > other than the requested node, instead of taking a partial slab from it. Hmmm... This would mean that we do not consult the partial lists of the other nodes. That is something to be fixed in the allocator. > However, since the allocated folio does not belong to the requested > node, it is deactivated and added to the partial slab list of the node > it belongs to. That should only occur if a request for an object for node X follows a request for an object from node Y. > This behavior can result in excessive memory usage when the requested > node has insufficient memory, as SLUB will repeatedly allocate folios > from other nodes without reusing the previously allocated ones. That is bad. Can we avoid that by verifying proper allocator behavior during deactivation and ensuring that it searches remote partial objects first before doing something drastic as going to the page allocator? > To prevent memory wastage, > when (node != NUMA_NO_NODE) && !(gfpflags & __GFP_THISNODE) is, > 1) try to get a partial slab from target node with GFP_NOWAIT | > __GFP_THISNODE opportunistically. Did we check the partial lists of that node first for available objects before going to the page allocator? get_any_partial() should do that. Maybe it is not called in the kmalloc_node case.