Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2864337lqt; Tue, 23 Apr 2024 04:11:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUKAV4+k3d8itRF84oOQ0+EKqcHaA0Hu9vnIBsQ6SShL+UbLRoI9LTbmFB5AKS6slgQ2VhWsKEV0qrSyP3KSwMj4OTNBTgEqDAZYpDEeA== X-Google-Smtp-Source: AGHT+IFhNfwKtpBZAZ7MLKqdA9pCmWg+iq3Q00EVtdO+Wk2DW2czC0YPN5sCSku+Mj7HSqwxiJk3 X-Received: by 2002:a05:6a20:12c5:b0:1a7:807:ca2 with SMTP id v5-20020a056a2012c500b001a708070ca2mr17651822pzg.29.1713870708512; Tue, 23 Apr 2024 04:11:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713870708; cv=pass; d=google.com; s=arc-20160816; b=zD0whtOsJN/cww/1voyrziENohGITffaqRta3WetFyRoL5SS3VNJexC9obHJTl2hwx sU2P3uMzgpa/q8zu5SqGJDHBFvBk0XHVUFZ2B0lsWDfNktpu9Lx39K5/2W5plYhybb+Z f1Wmtl3HTK3DH7MUKVN08mL894sVAm0koD932ofQWlLrm1mY6D/FnMSiAImLXniYQbGn aoD+E0PaN3OsD0oYbFzl2MasxCYfipuFwOw8XGbqaHCO9qvO28QBVb07yf9YdFvjeYvh gdJSmtX13PTKEIntDAwFBntAaEcn42TQque0++ugFuEuIkIg4PjofMXaFtyKrDIFwD66 6FpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=EjKJ4AU8u7PAwlJohTc2cAX1xjzwI5Yp1vDnN6OM75w=; fh=z0Cy5kKtJqwV/aqI6oSQtbXJrHwebAVDsS6JbdwMets=; b=ThRUYJppkOHOAKIqOkkjlIh9jLrWdvNsKSUJTc7G7Zve08HW3o6u6qGTt4sdsER0nP f4sReyZzlvGTpt7ix3cq/2f2vr6WTi/I2nPrDUbg8s4YD0NMwTNM6GadlP7zofwM+qWp Q8Aav09ZB/jj5TTLSO5icOrFgGTvhaDw3vC8mx7ylhw+6xiWdOVYNSFIEgYienAADR5t ADfFWGt+fiP10PDlPvMEbQpFrb0bw4Fs/YduZDg8a7r/7UepqRbYTKZZd9QipUQ9lCR3 gygr6oKLxZM20cU38Q+JY8kdQ3UIKRtlyccSAo304DlnM0TWywgqV8LsOxYQwF/wDKd1 gISw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZhzegNxe; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-154943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h7-20020a63e147000000b005dc4b84b38asi9192444pgk.72.2024.04.23.04.11.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 04:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZhzegNxe; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-154943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 D7E2BB24316 for ; Tue, 23 Apr 2024 11:05:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E679B745E2; Tue, 23 Apr 2024 11:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZhzegNxe" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 64E7F4691 for ; Tue, 23 Apr 2024 11:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713870314; cv=none; b=WqiZFG9mhD0cTmUPo5XJqS7WkJS14G9R1XcRWQcyFuI4SmYABi0aluwCvnMJnVUJkZvBBMCO0gIyiBIpy8CKx8tppOoqf/RWUAwNIk4AZYiD9EFohhr+W2ZbEMtsY3FmBwOCy3OUA0rlmNwHPXLZjiDsM6KJQGQ7eqMNPNwJ4Gs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713870314; c=relaxed/simple; bh=w1uSIpY9FpVcmDza1G4oH4ZkDqM7XGjOMrKhtpxXzEc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JXvHEZwtjySwl/j75I9RD3WLKQqVhi0qG3IKe0zOTDLLbAfpBricvSs3agMGb58kR5nzz00alnd3hXaJZd2bYC7t0bPviTj+d/SWBuckAPJrR4vkOP0Q2ZzYQrzGBc0WpoL/SgD4tRDQylnZXezQ9jKGcgTDMzL4V5imGmOcAsI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZhzegNxe; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713870312; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=EjKJ4AU8u7PAwlJohTc2cAX1xjzwI5Yp1vDnN6OM75w=; b=ZhzegNxe0pQeIrjw9JYJNR0sPjJq+TAedpHHWq82EBuuvDTGqJCAiZ9153o1bbV/U+Rsp3 hPBxH8flb/J2DhVbOwi49gH431kQsWPIOmA3yBrV5/ayI+O/cW4JC1l9/9XIsBaBoI7XPb x9w+PogmJXp7Qdwxr6Kgu5VH/llPDjs= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-uNN3C2xkN9OIdh75Thaz0g-1; Tue, 23 Apr 2024 07:05:11 -0400 X-MC-Unique: uNN3C2xkN9OIdh75Thaz0g-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-34b3fb802ddso788292f8f.0 for ; Tue, 23 Apr 2024 04:05:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713870310; x=1714475110; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EjKJ4AU8u7PAwlJohTc2cAX1xjzwI5Yp1vDnN6OM75w=; b=lJs6vaovQNlpf49+p75lOAPDrJ3XKJTLrkYDH67DfPKtyWaEHhjmDRbWdn4lU4bJOU IujqMgae9D1QdLJpBvLmcOmgccT3r6UiPeCwks/raMgx7KG96HCr3YxXThVOWMHlFuWF Z9QqCb5qBeNprm7A2kk18dSByCmDeLl4mEWD1nvaiXC14SPdfWsu6g97Jdv/Ya0vJI9A 8R4onuMwuH8zgDG6ehojU7jeSTIEOARJUQwHqf9gDM+npYW9faK/f9BWOGq6VC5gqpt4 6lsegr2t2qzm0FUo/jzKG1ZF2dR3A9R88MBga1CupBeLhrFkY1PG720+j67CqZPBHymR oDiQ== X-Forwarded-Encrypted: i=1; AJvYcCUw/0WXJ/BVsCDPkQw3yGmD6gWJv1HTVAndyUq0iJ7Rl6QQAhBTMJtbJm7TMUyOr020CPjeBrlXkt8EYXG5mKDk1wos5OntebAOZiC4 X-Gm-Message-State: AOJu0YyjgjLQZSfI+/rnKU4gpvk0WF1hKSvoFJD9ISzPBwEERqec4KHB t19UHjPkouWwQvWs6EtmvGn7pK2KCVm2TWOrswbz3StXSQSNR3qlJnyYKzxl+2pMPiKLJkkQqxU N9qaw2mDSQUF4ZTs76lm6tQxCmWRaP6oqt0+MupbHQ0czBWwBLjkF9rtyK48Hsg== X-Received: by 2002:adf:fed0:0:b0:33e:76d7:a8ad with SMTP id q16-20020adffed0000000b0033e76d7a8admr8915432wrs.38.1713870309763; Tue, 23 Apr 2024 04:05:09 -0700 (PDT) X-Received: by 2002:adf:fed0:0:b0:33e:76d7:a8ad with SMTP id q16-20020adffed0000000b0033e76d7a8admr8915407wrs.38.1713870309296; Tue, 23 Apr 2024 04:05:09 -0700 (PDT) Received: from ?IPV6:2003:cb:c706:fd00:fb07:92f8:8f0c:6a08? (p200300cbc706fd00fb0792f88f0c6a08.dip0.t-ipconnect.de. [2003:cb:c706:fd00:fb07:92f8:8f0c:6a08]) by smtp.gmail.com with ESMTPSA id r7-20020a05600c35c700b0041638a085d3sm23433800wmq.15.2024.04.23.04.05.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Apr 2024 04:05:08 -0700 (PDT) Message-ID: <8abcc8aa-473f-4a3c-a528-d32a0c8bfd75@redhat.com> Date: Tue, 23 Apr 2024 13:05:07 +0200 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: [RFC PATCH 0/5] add mTHP support for anonymous share pages To: Ryan Roberts , Baolin Wang , akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ying.huang@intel.com, shy828301@gmail.com, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <4b998e7d-153f-48cc-a9bb-8c84bb675581@arm.com> Content-Language: en-US From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0w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+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <4b998e7d-153f-48cc-a9bb-8c84bb675581@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 23.04.24 12:41, Ryan Roberts wrote: > On 22/04/2024 08:02, Baolin Wang wrote: >> Anonymous pages have already been supported for multi-size (mTHP) allocation >> through commit 19eaf44954df, that can allow THP to be configured through the >> sysfs interface located at '/sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled'. >> >> However, the anonymous shared pages will ignore the anonymous mTHP rule >> configured through the sysfs interface, and can only use the PMD-mapped >> THP, that is not reasonable. Many implement anonymous page sharing through >> mmap(MAP_SHARED | MAP_ANONYMOUS), especially in database usage scenarios, >> therefore, users expect to apply an unified mTHP strategy for anonymous pages, >> also including the anonymous shared pages, in order to enjoy the benefits of >> mTHP. For example, lower latency than PMD-mapped THP, smaller memory bloat >> than PMD-mapped THP, contiguous PTEs on ARM architecture to reduce TLB miss etc. > > This sounds like a very useful addition! > > Out of interest, can you point me at any workloads (and off-the-shelf benchmarks > for those workloads) that predominantly use shared anon memory? > >> >> The primary strategy is that, the use of huge pages for anonymous shared pages >> still follows the global control determined by the mount option "huge=" parameter >> or the sysfs interface at '/sys/kernel/mm/transparent_hugepage/shmem_enabled'. >> The utilization of mTHP is allowed only when the global 'huge' switch is enabled. >> Subsequently, the mTHP sysfs interface (/sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled) >> is checked to determine the mTHP size that can be used for large folio allocation >> for these anonymous shared pages. > > I'm not sure about this proposed control mechanism; won't it break > compatibility? I could be wrong, but I don't think shmem's use of THP used to > depend upon the value of /sys/kernel/mm/transparent_hugepage/enabled? So it > doesn't make sense to me that we now depend upon the > /sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled values (which by > default disables all sizes except 2M, which is set to "inherit" from > /sys/kernel/mm/transparent_hugepage/enabled). > > The other problem is that shmem_enabled has a different set of options > (always/never/within_size/advise/deny/force) to enabled (always/madvise/never) > > Perhaps it would be cleaner to do the same trick we did for enabled; Introduce > /mm/transparent_hugepage/hugepage-XXkb/shmem_enabled, which can have all the > same values as the top-level /sys/kernel/mm/transparent_hugepage/shmem_enabled, > plus the additional "inherit" option. By default all sizes will be set to > "never" except 2M, which is set to "inherit". Matches what I had in mind. -- Cheers, David / dhildenb