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 ADE12C67861 for ; Fri, 5 Apr 2024 16:58:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17D6D6B0096; Fri, 5 Apr 2024 12:58:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12E586B0098; Fri, 5 Apr 2024 12:58:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01C916B0099; Fri, 5 Apr 2024 12:58:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D7E0C6B0096 for ; Fri, 5 Apr 2024 12:58:51 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BD81A1A0274 for ; Fri, 5 Apr 2024 16:58:50 +0000 (UTC) X-FDA: 81976087620.06.CD4862A Received: from gentwo.org (gentwo.org [62.72.0.81]) by imf09.hostedemail.com (Postfix) with ESMTP id 3F053140020 for ; Fri, 5 Apr 2024 16:58:47 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none ("invalid DKIM record") header.d=gentwo.org header.s=default header.b=piJPZuR3; dmarc=pass (policy=none) header.from=gentwo.org; spf=pass (imf09.hostedemail.com: domain of cl@gentwo.org designates 62.72.0.81 as permitted sender) smtp.mailfrom=cl@gentwo.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712336328; 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:dkim-signature; bh=09aWB77GcwTGv7cWV+WUqIpB08zLvcLsBsdJpNtZe5o=; b=sxGEjbl5/mKS/Ww8J0uFJDu603JZxggdprdZyvWbqW7meHtqv16f3/vdoTAIT6ptYcJm77 Yio8VXF0ieie906l77/nu0aGX8qiXmAWPs5qmFah44XRxr8HcA6ZYHknXxH5i8kYuKqRHh 7x2GDtQVcp0LMk1cibJ0B7z+qGqbpHw= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none ("invalid DKIM record") header.d=gentwo.org header.s=default header.b=piJPZuR3; dmarc=pass (policy=none) header.from=gentwo.org; spf=pass (imf09.hostedemail.com: domain of cl@gentwo.org designates 62.72.0.81 as permitted sender) smtp.mailfrom=cl@gentwo.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712336328; a=rsa-sha256; cv=none; b=RkKaZq6bSzgTZjX6z+tRnuoDhohnse3R0NnYh1KJNVhy2t72uY8rrqqvSG+gDsXi9TV7Kq TGT8ly6WLgEGMsb846VkpJRqcvy0+xuP29rRlPk7bKLuvDPjvnOXxhPonS02B5ewpYfYYw M4uy5krkgL18dCbAhi5+9C9JvDaoaOE= 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> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3F053140020 X-Stat-Signature: ibzq7jhnekdqzfq9g6kn8mktedq5htd5 X-HE-Tag: 1712336327-172593 X-HE-Meta: U2FsdGVkX1+x2t+Br3n6/OOKaoz/KE6Y+AlNHtlD6n0stkZkaJ901hLJKhtBKMYCdlPLOrIiW7gJDBeGYkng5fTNRP7oKQg/UvdwsSZX9OEYd4UPwoHmvhE3W+PDWhkDNpsRKSRfe5eg67He/MwJK0EV7bIT69PxUFfXQ7M4A4wvdYREJ9auu3/e8kbws/PGqab8XqFQRAlyfRc8zjao+J+DItcEzJ04JJisyfDsQ4la5XS93JAEeubkcLhF/o4ugEImFb7Gr4nZctT55IArC3oEwnMbV3pZ4mbm2fdCp7GONcR7Vxn+j/IgqERD11ghJxaiTmqPpPlRvfYBQ12ThYhf25lchr4PbFF3/OMzXtfLvh9xf+kzxO7JmaOL7oqAjEqkFsmOstRQ70xePbBPkhyVDq9TyRaIsMZBZ79baYHbJMDENV2AFvNir3lOlm9LyBDH6ZzmUdA+r+9gi3vRP5bvGB/+QXiUBhYvhQcYScfxoFIjKjYTDA1NkEglZXrrkZqzZ/EiqYPiZtpM3LZHIsTA1ixTBdrUDJ6Yk+gQ8LlQSIJzQa09n/OmkCzf1CmXl3MtQx9SQAO4wPgxV8BLd03z2Bv41b7HXkDUwJarRe3a28W0X2GbcLEu1Nf3N4CzOFgYqTR6gvM4O5DxXEDWQPxRMyNBF5uF9mCdtUunf57QBgvX9ToL6Dr65XwbIvUt4Z7GQ5odxABmlSiojnTAIPQu3NYx/BuKhSLXKZXJ2ArpRFS3uuDCg8WgMsUnKIyTgvfj602yMfo5TAAxhDIMhj46ieLBgipRIoV9+lKirBaaFCA4QFqfwBpJUbN1M3HVmToFx1y2KCa3s+nDV0uOkzr2D2tXZAKjU/PZx3Mx4X0hJK3JDvbb9V8qFZ6dWg9ejBpyXuMpnzQ28LRU8GAyPXl/ZqgyrAWY X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 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.