Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1476500lqj; Tue, 4 Jun 2024 02:45:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLlJRXeR2MhgA/Qt2L0xKp+cfSTgEICoSJCPbbL1o0mZdX7Mo2wvIofn+TN4j/8VSHxXwxoAKkFkoYeFyPDTltAnQi0F9chO39mbGhZQ== X-Google-Smtp-Source: AGHT+IHsI4LBO5NkIvXcIig/fHFFBM/wp+h5boCb7y9aq3HO5ZnOWlo3T3LzTQBSwiq5aEcq/oFw X-Received: by 2002:a05:620a:b90:b0:794:b33f:3d82 with SMTP id af79cd13be357-794f5ebf325mr1168183385a.49.1717494334956; Tue, 04 Jun 2024 02:45:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717494334; cv=pass; d=google.com; s=arc-20160816; b=glfrbp6o+dHZ/gHDjTJLKe2Ts1M2DnY5x/wk7Oc6pOo44+9IerdUQ1GfCfjeIbn18B VcEYSYofi3ssH6oYcmKP6aZ0vzprxkXkHzmKHdFafvgi0OeX20NNLKo6QZTtn3v5SgMn E3tmqdO6otGfxa20EVFhqPhjXHdyFeJDk/E3I9QoImXAmNtiegqhgubAbYvrbKA393BN dboubUAXGVfLxYHGLZwIPvmNtF/93eiLDLe0jwy/2mmT51VWhMUGuXkI05nIHHEAoXiR X0hi0D6bXoTPzQtxsjB9j6RbfUxx3v1XCYBH45rOhh41CAm/MvtP3ZYiDNCklIJYxpdx Vqww== 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:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=vbTEU+QReOv/YXLhMYe94JXt/EprrLouNKIL/3NbTqU=; fh=azCq2zvCPUULlGOQcAYvVG2hTz5xLVFvXo4IGiN4mXs=; b=llN4CHthw81vBZ1Ni5NsQBpt4ovDq2Ks857jXo1SxEK2BqM+x3k1EEbtSx42oR11sh Q1TAWxjuX6grPzIG5TQTw5rKSkVJHbeEYFTq7R3x9bSN+4soigQEF7W4Lugu1gJQof4D wUeCJKAyQ9VUOTSbfbDk+BG3EBH97wXhbOg1gU3Up23PK3DrvvxsJ6Bc8aLHIdnlDOUK SOeKTFR4ErlXgLTSSQNxJ7QdcKJwm4qfb/XyWxR71x8fv3NBuCZjcsGYgvXXryNuoJrp WI/v9tv9/jI16XuIfXtZaX1I5YPg4o1XB1T37I6/PclZqsLG0wi0CvO1XsmroGmSXWOx FtsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=FeAVMx5R; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-200380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794f2f04eb0si1137456185a.155.2024.06.04.02.45.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=FeAVMx5R; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-200380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AE0DB1C20A45 for ; Tue, 4 Jun 2024 09:45:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC1C21448C0; Tue, 4 Jun 2024 09:45:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="FeAVMx5R" Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (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 C8A18143724 for ; Tue, 4 Jun 2024 09:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717494329; cv=none; b=C1RTm/StzJ9Ed9fkjuH0A+/j7WYS/LK0XntYPw0tL1fLtt+Xa2EbVuez3FfBZuvVz8YTi3qVXPByBD+tzgYTgjJAUy4Do40YiywHpa5dh1IcbNXRPZTfSH5woSEqjkYLEBgJlTEukDwLoXd+z4hhWMqRWsWUONa6sXHuTiKqv8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717494329; c=relaxed/simple; bh=q6OwPnDB/7iRSRzcquIUgaQdPaEF7T8E9hWdTrF07tU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=n5Zg1wYDLoPX2ETE2lfnPjptbhGOSPbDjW5nBjHDwSjN8NFPwXaZbA1Ir0o5gBPozVXGhVTMet1kZavBiGg0UJPdqLVPFNzNVGPQemF2aZJsLd2pM1DHexCmVcyPGVBzYxDBZy9gXEcatER66h/ukY6b3kbrVbWgT8tqNarFvVo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=FeAVMx5R; arc=none smtp.client-ip=115.124.30.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1717494323; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=vbTEU+QReOv/YXLhMYe94JXt/EprrLouNKIL/3NbTqU=; b=FeAVMx5RZW+bo6Hy9n0D8tG7AKOe/LoXzYAXit7nhq8pf7z7M2R2//lqWPoemiL7z8kGZOmxbkfsopiEnQ0V8WcpsONM7hUlGtwPDyNNzEEFwUyD7umSyh95pKurwCOGjCZEi7j3txdAaQdL+JLgqm2IVtO2ZUtGgSWeBBbHCs4= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067112;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0W7qjMx5_1717494320; Received: from 30.97.56.67(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W7qjMx5_1717494320) by smtp.aliyun-inc.com; Tue, 04 Jun 2024 17:45:21 +0800 Message-ID: Date: Tue, 4 Jun 2024 17:45:20 +0800 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 v3 0/6] add mTHP support for anonymous shmem To: Daniel Gomez , David Hildenbrand Cc: "akpm@linux-foundation.org" , "hughd@google.com" , "willy@infradead.org" , "wangkefeng.wang@huawei.com" , "ying.huang@intel.com" , "21cnbao@gmail.com" <21cnbao@gmail.com>, "ryan.roberts@arm.com" , "shy828301@gmail.com" , "ziy@nvidia.com" , "ioworker0@gmail.com" , Pankaj Raghav , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <502fb3df-b42b-4f0c-a98d-348c3d544721@redhat.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/6/4 16:18, Daniel Gomez wrote: > On Fri, May 31, 2024 at 01:13:48PM +0200, David Hildenbrand wrote: >>>> >>>> As a default, we should not be using large folios / mTHP for any shmem, >>>> just like we did with THP via shmem_enabled. This is what this series >>>> currently does, and is aprt of the whole mTHP user-space interface design. >>>> >>>> Further, the mTHP controls should control all of shmem, not only >>>> "anonymous shmem". >>> >>> Yes, that's what I thought and in my TODO list. >> >> Good, it would be helpful to coordinate with Daniel and Pankaj. > > I've integrated patches 11 and 12 from the lsf RFC thread [1] on top of Baolin's > v3 patches. You may find a version in my integration branch here [2]. I can > attach them here if it's preferred. > > [1] https://lore.kernel.org/all/20240515055719.32577-1-da.gomez@samsung.com/ > [2] https://gitlab.com/dkruces/linux-next/-/commits/next-20240604-shmem-mthp > > The point here is to combine the large folios strategy I proposed with mTHP > user controls. Would it make sense to limit the orders to the mapping order > calculated based on the size and index? IMO, for !anon shmem, this change makes sense to me. We should respect the size and mTHP should act as a order filter. For anon shmem, we should ignore the length, which you always set it to PAGE_SIZE in patch [1]. [1] https://gitlab.com/dkruces/linux-next/-/commit/edf02311fd6d86b355d3aeb74e67c8da6de3c569 > @@ -1765,6 +1798,10 @@ static struct folio *shmem_alloc_and_add_folio(struct vm_fault *vmf, > > order = highest_order(suitable_orders); > while (suitable_orders) { > + if (order > mapping_order) { > + order = next_order(&suitable_orders, order); > + continue; > + } > pages = 1UL << order; > index = round_down(index, pages); > folio = shmem_alloc_folio(gfp, order, info, index); > > Note: The branch still need to be adapted to include !anon mm.