Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp945144lqt; Fri, 7 Jun 2024 03:40:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEp/AHmNEClELy/x3wJPGVNazYupg3lzPx+T+vTAyOBjMaMI7NaNjJYY9mgefofR6WHSi7xESXXh6luitOn2/yIfzwuhqCV1bnPf6akw== X-Google-Smtp-Source: AGHT+IECYfQlY1fR3cmPiSkWHSVoDUDtmBoOC1+9NOSvvBUjikMEXQRG0E6e19HA4U1W1Q6VoO+O X-Received: by 2002:a2e:6a10:0:b0:2e0:da20:2502 with SMTP id 38308e7fff4ca-2eadce9ce9fmr17429991fa.49.1717756814419; Fri, 07 Jun 2024 03:40:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717756814; cv=pass; d=google.com; s=arc-20160816; b=aLCSqqn4QWsMNtBxLoCRpEGidQi7R0+Mr8LWEz4NZcqKhjjbaHQcpe+7nlEm/3qnEN H9qtpLex166RViRdDcQlLO80UuBv21eUj78rsGRQp1DdrdMxdND0+unzQlzU/vt1ohtj fkIfNJsFfn8TOak2IvZ4+PqmQ6yMOPFozU1U2v8Mljjh7udE+OGZnKRYbZn4ny5j+Ez5 LCglToR22wkcIF0W9jshXRhbeVRx4NN9Sn6nDd/wq0o8iGQgzIAlerco+4w+HIUxzkdI 7wDSxcFW6g9jYqbAiaa+Ze6UpqfmpJ+XOPZVGyJzNOOisfU8VVXFN3i6lOZCciEuuE2Q MjoQ== 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 :content-language:from:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=npA+mrK958AR5fc95CrozI0zOPbGNdw6cZrPjm/DSfg=; fh=UNG3Hfj5sHGrsnGAskBjMRxSyUB6fLz7O+sCAVkPI+A=; b=WAu0pJ4lqPlIoO0QRXgrQvo51YwgOTsThF5W97tmpazAX1kP7UbUbkv6IkqFQbgEMG XmIksXwU2HTNxiK8bTOB4stxnUgYozeTp6GnjhBKjzrhyZdFoGZ+oetWlhMfymvsASmg vlQjwwavorfSFywibx2K1yEbz9CYoiQ3i6Zc1BAvh3bT4+9Q51gNdDVvTF0M4jotwTN+ s5Z1J7exRTcB+QfIbw+5/VjjNb82/PjFKx7Nw/BDgwMWusrBPgKY4bzgQfnZNOekZomi 99Sz8URwRhVFqXjy0F3bY83tAR/7IfFKCT0OvQjft5wqxc1FQ+o+alFEe1dfbS4OiLXL 3rOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIL1peXP; 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-205842-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c807084d8si170922566b.538.2024.06.07.03.40.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 03:40:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205842-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIL1peXP; 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-205842-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205842-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D90621F2519C for ; Fri, 7 Jun 2024 10:40:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 508D2158214; Fri, 7 Jun 2024 10:40:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jIL1peXP" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 5F72815D5D6 for ; Fri, 7 Jun 2024 10:40:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717756805; cv=none; b=f9ZO3JZeoGAGZik+fFlxmU0LAucRW0N3hauKq60d/RTFnarlL8VqXEYPIgOMS+HO4s9I59f+OyrvTeqGGzenIYMYH06cdoFUdiV1GGGOpmXtwLjnSOmhUPtk+Rt9c0t+8wG/jt/oK3/RsADcPX6tf9/obPf7UzFZMR0TR/+bqIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717756805; c=relaxed/simple; bh=RNYspcEPwyIQJKh7EQUxXoVtBdyfWedxUyCXv/X/UZ8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fi8AIs+6RWYCszeS2zeInSOSnHWeYArcUvIOYs9tRSjy2WpXWwaL5HInavB4FMaTrwZoRuhF3NBIe1KechPbUz+CY4IJOkI3ERV+nvKDe36u2d+E/yjYvSmb7/LL7NxmgfBq8S23E4Koz9Aez4aJoXaeP+bbjMaR0pPGkx8JEZc= 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=jIL1peXP; arc=none smtp.client-ip=170.10.129.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=1717756802; 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=npA+mrK958AR5fc95CrozI0zOPbGNdw6cZrPjm/DSfg=; b=jIL1peXPPSMQYD3oogV6S1+a5C+eehcI9+ogtmvuM3wgItB+8ZGQGvFGstcLA4Z4SQRQ78 z0e9yWD13ipngoP47droKnr10Uxt3b/Cm54F4wZiWFpctv3n6hpbgXjbLc7CVYQQGy6dQZ 7APPLTU/dHDPuAN3/mXLMEjYI0gKdek= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-T7-yyQXwPcqKt0xXjnRkuQ-1; Fri, 07 Jun 2024 06:40:00 -0400 X-MC-Unique: T7-yyQXwPcqKt0xXjnRkuQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-421739476b3so1961425e9.2 for ; Fri, 07 Jun 2024 03:40:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717756799; x=1718361599; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from: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=npA+mrK958AR5fc95CrozI0zOPbGNdw6cZrPjm/DSfg=; b=NV4behSNsv80rdt699UsuSa28kUFEo0RwhCnRRxA/TscGc1n+TtJpQ+6oEqnXWV+ld 04hVv9nw7YTdnGjydYSLgSFEQkx6uSa2PUVS7k9hEfZSqrb/Pzs0zzAKoeQF9CR7y7cz oh3yGVUqd6DbVbQdskymPOA0CmPKhDXtppIn5/9hooqRs2l3e9eOp9sspQzpN+2kzKM/ Js39N2xslvVf9l6fUCpyfF8X+dsFYf0CJY6ajEPY6VotcGhJ8DrAN9L+YtZ45bRQH+JP 3cxUjyeezarh5uERLxxs4pVXZi1dQmh2Dmgln+QFGusFivK4ZzZIywu+fPJSOs01g5BZ 9NZA== X-Forwarded-Encrypted: i=1; AJvYcCVaccXkBjYPH1Bj0oLgAgBSPp44pfzXqCdB81OBmDTY+X+SY4Plj8s521LJ84MoL9jG0NQoQQTi2p5eFF/XTTX7e1WlQhdpRrqsTBqU X-Gm-Message-State: AOJu0YyMDmFmYs16mG+KwUEv4aDD/YqriDXIrDML9TNOKR+alq6Ki0gi UNqN0BF64V3PQbAUF/aIiuoLoTfcNGmImQt5ftRwTQ3kGYhK2eKKWlVv54nZol0sJw/tl+RFnlW UzsBy32rvwqaB+gieIeG42XTKnajPKYD65NQh1TAJObnYny1j9UIutKWu2g2lhw== X-Received: by 2002:a05:600c:34d5:b0:420:fed7:2903 with SMTP id 5b1f17b1804b1-421649fbfa9mr24090445e9.15.1717756799565; Fri, 07 Jun 2024 03:39:59 -0700 (PDT) X-Received: by 2002:a05:600c:34d5:b0:420:fed7:2903 with SMTP id 5b1f17b1804b1-421649fbfa9mr24090185e9.15.1717756799059; Fri, 07 Jun 2024 03:39:59 -0700 (PDT) Received: from ?IPV6:2003:cb:c71a:2200:31c4:4d18:1bdd:fb7a? (p200300cbc71a220031c44d181bddfb7a.dip0.t-ipconnect.de. [2003:cb:c71a:2200:31c4:4d18:1bdd:fb7a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-421661ecda2sm18350345e9.2.2024.06.07.03.39.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Jun 2024 03:39:58 -0700 (PDT) Message-ID: Date: Fri, 7 Jun 2024 12:39:57 +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: [PATCH v3 0/6] add mTHP support for anonymous shmem To: Daniel Gomez Cc: Baolin Wang , "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> <5mezgqzg7wmd4iq2d2q3aentziosetwcll3tgdbl3mhriseyv3@pgxsux7qvxno> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/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6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 07.06.24 11:05, Daniel Gomez wrote: > On Thu, Jun 06, 2024 at 10:38:22AM +0200, David Hildenbrand wrote: >> On 06.06.24 05:31, Baolin Wang wrote: >>> >>> >>> On 2024/6/4 20:05, Daniel Gomez wrote: >>>> On Tue, Jun 04, 2024 at 05:45:20PM +0800, Baolin Wang wrote: >>>>> >>>>> >>>>> 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://protect2.fireeye.com/v1/url?k=a23e7c06-c3b56926-a23ff749-74fe485fb347-371ca2bfd5d9869f&q=1&e=6974304e-a786-4255-93a7-57498540241c&u=https%3A%2F%2Fgitlab.com%2Fdkruces%2Flinux-next%2F-%2Fcommits%2Fnext-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. >>>> >>>> What about respecing the size when within_size flag is enabled? Then, 'always' >>>> would allocate mTHP enabled folios, regardless of the size. And 'never' >>>> would ignore mTHP and size. So, 'never' can be used for this 'safe' boot case >>>> mentioned in the discussion. >>> >>> Looks reasonable to me. What do you think, David? >>> >> >> That mimics existing PMD-THP behavior, right? >> >> With "within_size", we must not exceed the size, with "always", we may >> exceed the size. > > But right now we only check the inode size. With large folio support in > write_iter() we can have access to the length as well. I think this would solve > (paratially?) the cases where we don't have access to the file size and if we > perform writes in bigger chunks. > > E.g. xfs_io -t -f -c "pwrite -b 2M -S 0x58 0 2M" /mnt/test/file > > For 'within_size', the example above would allocate 512 pages instead of one > huge page. After patches [1] [2] we can get the size of the write to allocate > whatever mTHP/THP makes more sense for the length being passed. > Yes, although this sounds like an optimization/change we should be doing separately I guess. > [1] https://lore.kernel.org/all/20240527163616.1135968-2-hch@lst.de/ > [2] https://lore.kernel.org/all/20240515055719.32577-12-da.gomez@samsung.com/ > > Here a quick hack for THP: > > @@ -561,7 +561,8 @@ bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force, > case SHMEM_HUGE_WITHIN_SIZE: > index = round_up(index + 1, HPAGE_PMD_NR); > i_size = round_up(i_size_read(inode), PAGE_SIZE); > - if (i_size >> PAGE_SHIFT >= index) > + if ((i_size >> PAGE_SHIFT >= index) || > + (len >> PAGE_SHIFT >= index)) > return true; > fallthrough; > > >> >>> And what about 'advise' option? Silimar to 'within_size'? >> >> Good question. What's the behavior of PMD-THP? I would assume it behaves >> like "within_size", because in the common case we mmap (+advise) only within >> the size of the file, not exceeding it. > > It allocates a huge page on request when MADV_HUGEPAGE (regardless of the size). > Interesting, so we should do the same. Thanks! -- Cheers, David / dhildenb