Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp556134lqc; Fri, 8 Mar 2024 05:45:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCspOfr6O7pS4K/Y7YL0UmFx7qaKp1ide8RaNY+RJa54van5tVFXi1qk6fs0TkDZND5lRU8N5EozMxlUd3U/6hbOyMJK5hkno49S0LHg== X-Google-Smtp-Source: AGHT+IFt76wcD2H2Vnp4IYkvylv2EYOPcQrib8OIE3KNxSr95eqoCFwDrQlzbH1kWura/7yZzFzS X-Received: by 2002:a05:651c:1411:b0:2d2:3c88:cd57 with SMTP id u17-20020a05651c141100b002d23c88cd57mr3058686lje.32.1709905549966; Fri, 08 Mar 2024 05:45:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709905549; cv=pass; d=google.com; s=arc-20160816; b=j02tS4rkoZLT0x7/LKr6NMijJ9PcVOOmsz8N2v5bpJit4lahTDHWZj1JZVSv4LZL8D 6p+et5o4sNqGgUJWJUWlaod2M/Eg9vDF9r9pTIAnezAetJP0GvWEvOg48CWvGIPs80K1 PNBWr19TRAdGYuYiRCKX8RQrYj5vut/324s8duv9RsEtWnfOsNpwFXIpmFUz7eCwXY7F xpZO7xDQZRhGCK6gl4lYnt2/8vzKaHgCaYi98hEXXez1Mx33LTQpJNxgYyhu8I8qFxch NQk51s0w0VuXR+M3mOQ1QOpDkn41J2FMq2j0cyAIwDyZJGJMLNsOC4ZmH4k/iAPMBSkG t7rA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=lgHJ3I5aBmiUxdHDSMa5q0puhk1KSbDKZSwmwX7mxlw=; fh=5kmrWl4nFWP5To05EjD7UpXx89Nz1pxSXVzL3yi1StA=; b=bdi0oWrAfRk4xiaMX2qDbil+9gqwpFE7IRD4ztT7Nz6tkmfZvb1Z/N4fNotGOd1ZDc EakbqXKQBGaoJFL6h5APXaACKo+WBmkkHqzP60H2DwZIj6IayuRKsRR1hDBMUKHOdYoY T81eqdoelmbW8p/TTTMRl7R3oa5wUyWxhEQ2w8Ej722L41o91FYaITJoO03eQpLd/6nB PBxuugiZwLyiWmQr6/Sdsl5HhDE1w/IJ18p4sx+P04EAIhewrvBTHg89ARB+Bb8KVHpp 6hZwfAUoXQ0xD2ZGZ3Ve5SHdlKMHs0ERMfRb/FWPyoF8nElgDwhU7pkjPLiI41AjqofB Az1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-97100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 fe4-20020a056402390400b005682b03ea46si607131edb.59.2024.03.08.05.45.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 05:45:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97100-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 spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-97100-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 685821F217D5 for ; Fri, 8 Mar 2024 13:45:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F16D43BBE0; Fri, 8 Mar 2024 13:45:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 580D663B8 for ; Fri, 8 Mar 2024 13:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709905543; cv=none; b=XUpjsSO/WtWbOOuUpaSU5EAMWP3LpYVNNS4EOS7B+AWdnhQ8PU6NRMuQOSemb86harERK7oIO7SM1o4Ni8SPTtW4uEADbMumJn6fmSMJmbFud8++t3AA+44A9i9gY++Y6ickn0rnNlB+rstkICTTEnLuytenbEHWC5GfqoCctzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709905543; c=relaxed/simple; bh=9xtUBUdedaQUnq7S4bilUju7BsfYPeHcOERY0pwxc+k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kC5m+mMqo3/g93JieUCSjtZIYWH5hTWgfebpdzVMFHKvet45lWUDh6TYQ3L7k4nEeNwtdjWmXZRrFuR+H9u9iszo+b1cZGGp8o7HdoyP7ehmxF340PucuiMZaV7whYXw64Hn7MTUKvSkb6+RL7Naqwu/iocOLFVd68fxNzpZy9s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1339DC15; Fri, 8 Mar 2024 05:46:17 -0800 (PST) Received: from [10.57.70.163] (unknown [10.57.70.163]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 88B433F762; Fri, 8 Mar 2024 05:45:36 -0800 (PST) Message-ID: <252bac83-bf5e-4c40-a696-ac093da41fa3@arm.com> Date: Fri, 8 Mar 2024 13:45:34 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm: prohibit the last subpage from reusing the entire large folio Content-Language: en-GB To: David Hildenbrand , Barry Song <21cnbao@gmail.com>, akpm@linux-foundation.org, linux-mm@kvack.org Cc: minchan@kernel.org, fengwei.yin@intel.com, linux-kernel@vger.kernel.org, mhocko@suse.com, peterx@redhat.com, shy828301@gmail.com, songmuchun@bytedance.com, wangkefeng.wang@huawei.com, xiehuan09@gmail.com, zokeefe@google.com, chrisl@kernel.org, yuzhao@google.com, Barry Song , Lance Yang References: <20240308092721.144735-1-21cnbao@gmail.com> <519fd6a7-072e-43a2-a9a8-2467ee783524@redhat.com> <8e994734-1d3a-4c51-9c0b-4e2ce945f198@redhat.com> From: Ryan Roberts In-Reply-To: <8e994734-1d3a-4c51-9c0b-4e2ce945f198@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 08/03/2024 13:24, David Hildenbrand wrote: >>>> This patch migrates the last subpage to a small folio and immediately >>>> returns the large folio to the system. It benefits both memory availability >>>> and anti-fragmentation. >>> >>> It might be controversial optimization, and as Ryan said, there, are likely >>> other cases where we'd want to migrate off-of a thp if possible earlier. >> >> Personally, I think there might also be cases where you want to copy/reuse the >> entire large folio. If you're application is using 16K THPs perhaps it's a >> bigger win to just treat it like a base page? I expect the cost/benefit will >> change as the THP size increases? > > Yes, I think for small folios (i.e., 16KiB) it will be rather easy to make a > decision. The larger the folio, the larger the page fault latency due to > scanning, copying, modifying, which can easily turn undesirable. > > At least when it comes to page reuse, I have some simple backup plans for small > folios if I won't be able to make progress with my other approach. Do you mean "small large folios" here? i.e. order >= 1? If so, great! For larger > folios, it won't really work/be desirable, though. >