Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1578369rdb; Wed, 31 Jan 2024 03:03:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGB4yj9P2uOHCOsxYdNaatQAluWvOspIGcyuY+/9uvD+bOpYggU5Rsfvu3K/Tz9rzmHj2I6 X-Received: by 2002:a17:906:f1d4:b0:a35:ad04:af7f with SMTP id gx20-20020a170906f1d400b00a35ad04af7fmr783902ejb.0.1706699008754; Wed, 31 Jan 2024 03:03:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706699008; cv=pass; d=google.com; s=arc-20160816; b=htHwZ/Lh+7uSywx4RF4tN6Yg6Yk1uCRwxFRn8CXM+db6QYNWgsurnKuVbuuFjQESjh U6S+ZtZK/ee4k5YGWhU5idkjorEWaSx7+7GxkHxvwVd4wtfol80Fj8B6IFSomqUd7rNA XuKIBtbrXEJlXAP9WHTaROpli/jxn1rwCxJO9Q0XUYog1/N/RaY4m7ZRmdbTWZKzSbcY 0QUCMjhWSwH/3Vu+tua0DiXwaiuViTIZoCPG3WqaBYwiIrkLtjlFJCgbOXFLGQbEkZSk x0CyNZHpheP7+9Oihh/chgw4btwnkDhIsaS7VpEU6PTWGPSFIY6zIDa2ZaNsvAPFxqXh dTdg== 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 :references:cc:to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=olrIksRwu/OB7Bur4QOxK7MpIEfH+wiCW8yB+1Kffm8=; fh=07sPFKOod2u6WzGpfmldHRj1aZ1eYB9I1/JM0Gdm++E=; b=Z//JseymftAPFGy+R4zOf697uHQbF8WmcAv2/Dss6NgqlIVWOKp/tIrQriepsUgP4J gL4wfW1oPRe8guWELwK7snWKvIEqPwzGuGR70Ce5c/Qfzy21FOxwH/ayY19rloDN4gAA OVHPkAFvV2RWtwVSn/Il4AoPCIwUXFl0XbxKOctanT++3WRZlOpXV9BAEKE8FmN5Wloc RhD/A0N69Bpb5QMLOxN03AXkatp4wOE0GXi4FGk1RiB6oJBuyc8PMiTbh58LMFVR2YP6 09UPJKnyz0IF3h56J6b1ykuo5CpjBRYlbBe8y1ROq5OzXeo5JXGHariXiXv/pWbUm90O vtHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VXtCMcLL; 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-46196-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCWQWM3s78pAwzgl2hLFGnIU4xsAJ02XYlyDm2X8PRfvRRNeCAfNQSFZsFr1J1TzFUaTDsbLfOImQPtsuGZtVttaj/x/3Cssr7imKuIpAw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qh9-20020a170906eca900b00a318fd41ccfsi5370268ejb.597.2024.01.31.03.03.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:03:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46196-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=VXtCMcLL; 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-46196-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46196-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 3D88D1F2DC9A for ; Wed, 31 Jan 2024 10:17:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1720569D0E; Wed, 31 Jan 2024 10:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VXtCMcLL" 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 DA36B6996B for ; Wed, 31 Jan 2024 10:16:07 +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=1706696169; cv=none; b=QCMzgs1CqB9htjfMa5NWD8ipseAaYkEUqsHeUHexoG664qArAMrKSePB7wXr4bQFg+duA4yez9y9okUNpHOFjp2iaRBIXbr6n6jD5xpOY2747HTGxNku5j/lL0FXqecfiAEjmg8GRWYUDo1EjdDaB1D1mcG0zWszv4hkPTAtO3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706696169; c=relaxed/simple; bh=+fUuFbI+H/SuBr2rM99Lw5pc13uDCdDY1YWEmbLISaM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FznVhvIStxrtAdpz69ZvHDNIE259Sl2tt7TG2PFE3XMdo/oQk9LdIUJ6FXxOWzQw6RPmTN69CiPgP1grcRyoApV2tpJiDAysSTv9RIlwcQ87wFdISwtMjhPow77rPRT77ZotI3KuktpxWDvfZG9c186BHhhyTOBwn/BjbqFFvgQ= 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=VXtCMcLL; 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=1706696166; 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=olrIksRwu/OB7Bur4QOxK7MpIEfH+wiCW8yB+1Kffm8=; b=VXtCMcLLumeJJEWpPzPK2zKyzbNBAB39Ahlsit9XtH2Q0xEmdEK9PecI+Iy473T7zzzBCQ kWyZFD2cCWc76SA+/KSJADbLEv2LjU2b8oTBwotyElvpNjCH6UrjowUnWBLOI0TNLKe6v0 ilnsAvJ0u8eFL/UTEbGnlW2KuAy7psg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-394-F8XBZgw1MIKNfpRmmeOyeQ-1; Wed, 31 Jan 2024 05:16:04 -0500 X-MC-Unique: F8XBZgw1MIKNfpRmmeOyeQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40ef75bea80so16452705e9.1 for ; Wed, 31 Jan 2024 02:16:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706696163; x=1707300963; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=olrIksRwu/OB7Bur4QOxK7MpIEfH+wiCW8yB+1Kffm8=; b=rL6ZMFc0atSb4NP46ra2AbV8NDDMZI+am/Yi80iHzn856Kw18ly2s2flSoCD+8DiCg I39Wd5btmiSC9k7yUalCnOQN7xJWkf6qlU2OK9JLpwSO8kGnSj8Bn+7ZINuNb7/JP4Pv ZHv4IjiwFWrp8UDRYoBtnIouUP4qT8m+6GiGskOttVB2YP8aLBP7Xjx6tK9vvBPPRgCW tyvDIdCMEBefMrjEoxTTaNcVLMO8tQr59Ln+6v+jh1hgUX2Y54ahdd/N0LEaPcSvbfSD N3/cR4haCHfFW68Ga2vHC+w5jhJAxQV1KAHy+TeV4zapIB4Xk0Xn9W6QPKP2kEe8eh85 cEqA== X-Gm-Message-State: AOJu0YxE9ftIxFVdG0Vb4CzUs2OzOIP9NKnGJZulpNhx+achWS92EPEs 6RHfM36EhKYm2Ti+FlQGOScUp/reWqdJjRQ/TLYJkGLE7qwtswU9pAbURtX4rKUaXfg5LNkchUf 528aIpLR/fR1tJQoTTxnesPpJqxoVnMamLqIR1xbTejkqwLAjRna3hNv5i4X45g== X-Received: by 2002:a05:600c:5487:b0:40e:6193:b1a5 with SMTP id iv7-20020a05600c548700b0040e6193b1a5mr854939wmb.39.1706696163434; Wed, 31 Jan 2024 02:16:03 -0800 (PST) X-Received: by 2002:a05:600c:5487:b0:40e:6193:b1a5 with SMTP id iv7-20020a05600c548700b0040e6193b1a5mr854918wmb.39.1706696162974; Wed, 31 Jan 2024 02:16:02 -0800 (PST) Received: from [10.32.64.237] (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id o7-20020a05600c4fc700b0040efb20fa6csm1144646wmq.47.2024.01.31.02.16.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 31 Jan 2024 02:16:02 -0800 (PST) Message-ID: Date: Wed, 31 Jan 2024 11:16:01 +0100 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 v1 0/9] mm/memory: optimize unmap/zap with PTE-mapped THP Content-Language: en-US To: Yin Fengwei , linux-kernel@vger.kernel.org, Linus Torvalds , Michal Hocko Cc: linux-mm@kvack.org, Andrew Morton , Matthew Wilcox , Ryan Roberts , Catalin Marinas , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Michael Ellerman , Christophe Leroy , "Naveen N. Rao" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, "Huang, Ying" References: <20240129143221.263763-1-david@redhat.com> <4ef64fd1-f605-4ddf-82e6-74b5e2c43892@intel.com> 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+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQR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7wC7iKfoUTv03iO9El5f 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: <4ef64fd1-f605-4ddf-82e6-74b5e2c43892@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 31.01.24 03:20, Yin Fengwei wrote: > On 1/29/24 22:32, David Hildenbrand wrote: >> This series is based on [1] and must be applied on top of it. >> Similar to what we did with fork(), let's implement PTE batching >> during unmap/zap when processing PTE-mapped THPs. >> >> We collect consecutive PTEs that map consecutive pages of the same large >> folio, making sure that the other PTE bits are compatible, and (a) adjust >> the refcount only once per batch, (b) call rmap handling functions only >> once per batch, (c) perform batch PTE setting/updates and (d) perform TLB >> entry removal once per batch. >> >> Ryan was previously working on this in the context of cont-pte for >> arm64, int latest iteration [2] with a focus on arm6 with cont-pte only. >> This series implements the optimization for all architectures, independent >> of such PTE bits, teaches MMU gather/TLB code to be fully aware of such >> large-folio-pages batches as well, and amkes use of our new rmap batching >> function when removing the rmap. >> >> To achieve that, we have to enlighten MMU gather / page freeing code >> (i.e., everything that consumes encoded_page) to process unmapping >> of consecutive pages that all belong to the same large folio. I'm being >> very careful to not degrade order-0 performance, and it looks like I >> managed to achieve that. > Let's CC Linus and Michal to make sure I'm not daydreaming. Relevant patch: https://lkml.kernel.org/r/20240129143221.263763-8-david@redhat.com Context: I'm adjusting MMU gather code to support batching of consecutive pages that belong to the same large folio, when unmapping/zapping PTEs. For small folios, there is no (relevant) change. Imagine we have a PTE-mapped THP (2M folio -> 512 pages) and zap all 512 PTEs: Instead of adding 512 individual encoded_page entries, we add a combined entry that expresses "page+nr_pages". That allows for "easily" adding various other per-folio batching (refcount, rmap, swap freeing). The implication is, that we can now batch effective more pages with large folios, exceeding the old 10000 limit. The number of involved *folios* does not increase, though. > One possible scenario: > If all the folio is 2M size folio, then one full batch could hold 510M memory. > Is it too much regarding one full batch before just can hold (2M - 4096 * 2) > memory? Excellent point, I think there are three parts to it: (1) Batch pages / folio fragments per batch page Before this change (and with 4k folios) we have exactly one page (4k) per encoded_page entry in the batch. Now, we can have (with 2M folios), 512 pages for every two encoded_page entries (page+nr_pages) in a batch page. So an average ~256 pages per encoded_page entry. So one batch page can now store in the worst case ~256 times the number of pages, but the number of folio fragments ("pages+nr_pages") would not increase. The time it takes to perform the actual page freeing of a batch will not be 256 times higher -- the time is expected to be much closer to the old time (i.e., not freeing more folios). (2) Delayed rmap handling We limit batching early (see tlb_next_batch()) when we have delayed rmap pending. Reason being, that we don't want to check for many entries if they require delayed rmap handling, while still holding the page table lock (see tlb_flush_rmaps()), because we have to remove the rmap before dropping the PTL. Note that we perform the check whether we need delayed rmap handling per page+nr_pages entry, not per page. So we won't perform more such checks. Once we set tlb->delayed_rmap (because we add one entry that requires it), we already force a flush before dropping the PT lock. So once we get a single delayed rmap entry in there, we will not batch more than we could have in the same page table: so not more than 512 entries (x86-64) in the worst case. So it will still be bounded, and not significantly more than what we had before. So regarding delayed rmap handling I think this should be fine. (3) Total patched pages MAX_GATHER_BATCH_COUNT effectively limits the number of pages we allocate (full batches), and thereby limits the number of pages we were able to batch. The old limit was ~10000 pages, now we could batch ~5000 folio fragments (page+nr_pages), resulting int the "times 256" increase in the worst case on x86-64 as you point out. This 10000 pages limit was introduced in 53a59fc67f97 ("mm: limit mmu_gather batching to fix soft lockups on !CONFIG_PREEMPT") where we wanted to handle soft-lockups. As the number of effective folios we are freeing does not increase, I *think* this should be fine. If any of that is a problem, we would have to keep track of the total number of pages in our batch, and stop as soon as we hit our 10000 limit -- independent of page vs. folio fragment. Something I would like to avoid of possible. -- Cheers, David / dhildenb