Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp571857lqp; Fri, 5 Apr 2024 02:24:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkr8JGQkBhbIqSbDzE1yffakxxxZwtTE/FiO5xJXq9B2p94vVI+sNPm6+QbVZbFrHZHcoGkojU0dSfOTViH3B2oyKPO+Z61pBsOXqG3w== X-Google-Smtp-Source: AGHT+IHN+1vlzfmcbLjVvxj/Pnapmc2FxMN//Mn9s8J1+u8dpo3abvu7oLcn4rbZWEmWJgVT/bqy X-Received: by 2002:a50:8753:0:b0:56e:2dfb:da7b with SMTP id 19-20020a508753000000b0056e2dfbda7bmr989328edv.0.1712309091938; Fri, 05 Apr 2024 02:24:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712309091; cv=pass; d=google.com; s=arc-20160816; b=HMkupsri+FaiZU8S8eR9Q38C/bJnLt4R1elsbHMDe01w6uEAXwiT/qFALSjRgRPphL BbGwT2zwfG5TWyXpDqGG3wYwgUojUG07dJTI4YpJk8g7i0IWR26/zyEnj8jCl0eauJ9r 4DQG0Mb4ngU/fSm3rvFLKhFPchy+fc0rtqzy3KFcEMd0ZjjsIWfjGIBl4NVoP8YOrIDR fy1AMr5xKGvHbHXQ+vy3oZmiumNn/UVdvYRKk1vWVbGR5hJQOpA5qHpmZfgmgpoQtgVl YIwKzDQSLdM1soT5DAk374LvO0z57ANal8ZfICCR6r697DoevVLRKZf/BbErkyDMF4gI A/5Q== 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=5CUGEh7qt513XXq70meozxW0RhRyZE2IyjxQxM/2VZo=; fh=DcM7tRnwBuTIYpGI0yv6dxxK6yBmftsC/UkUbmfKT8o=; b=qBYJzdr2QMKO0VBIqq/qyW6R2cwQRQ8LcKGyv8rqOMMlGZMYaiXg7TxO42eF4ZPHW+ a/66Fl1GYWbFY3W+k08ekYlM0kcbQgi0hDVCbgbBH8Bm/kzeLqsn0tBIC8aLKofeuJ5/ kEbnOYzXRybdPaIIQ/saCApJnpF8zGtULSTFeeMT2PMDxnL4rnR5C0Gj/tUFS10oGa56 5zgendhcFI03xH6sgFJyZmRe5c85X3zZO2PodYeWKeQASYPgXpYM70vmauu3IDqR3wtN gWNHHNAwlPocizldRL4lZLvpGzP3xFKVn7GT5T04EZW6rIhwHc+UTeXhR9m4lVajIzbJ 6h6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X+Ab7Aam; 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-132731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132731-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 x1-20020a05640226c100b0056e2b59b17fsi583989edd.48.2024.04.05.02.24.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 02:24:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132731-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=X+Ab7Aam; 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-132731-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132731-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 4E61A1F2268C for ; Fri, 5 Apr 2024 09:24:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A95FB15FD15; Fri, 5 Apr 2024 09:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="X+Ab7Aam" 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 E82C7145B09 for ; Fri, 5 Apr 2024 09:24:41 +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=1712309083; cv=none; b=EyQJMbGcF2/7oBqkoNjXzymd9EOcpAdXujo4FNqG6Hn1nTXBIdbb3IH6kV8JjcapbuGfziDH5B5Z6ZwSambqPsIuHR5ircBotnOWygGWM5X0CAtv+dqfJLqJzbRnH/qevLfzax/lecYhgFAG1JISIumHmb9YUZpRFwDtDAT6oV0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712309083; c=relaxed/simple; bh=7e+GZYsKL7Gf+BXm+BdH4bf3XLqLFRAkE4luSGnT9kY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pG0FQBaf8CVgrY93479kvgYSW3VvfYgrP5SwicLVywYLwvgTXMJDvS6UR5oI2W2mby0Ko+qVONPp1Ym8eJzPjpl1JhHk5QsM96dfLhOG4vofD70cPKnPdB691loLzkls5AzWihx3H8QPiuGcGRhmgfeYInKVPMUF4U75bFSwONU= 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=X+Ab7Aam; 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=1712309081; 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=5CUGEh7qt513XXq70meozxW0RhRyZE2IyjxQxM/2VZo=; b=X+Ab7AamwhWT2pWYcr0MW/pP63k9W6OoUlSClOsilDXukO8EA31tRlsbtSShU04dzG+UEy Juu8IpsZq7Ipmur8JPkN7gsVBo5qBwJKMp1L0U5VYDonj8XTWkczQozM7wu39HMTAv5af8 D/P7AdyFMZxlrW/hCdkU+jcHn/FUllM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-mLm2tNPAPnSgGxRcazK7CQ-1; Fri, 05 Apr 2024 05:24:39 -0400 X-MC-Unique: mLm2tNPAPnSgGxRcazK7CQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3437032fe82so1534046f8f.0 for ; Fri, 05 Apr 2024 02:24:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712309078; x=1712913878; 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=5CUGEh7qt513XXq70meozxW0RhRyZE2IyjxQxM/2VZo=; b=eRce0eFRuilfScO80Zdh4QC9ydVm0eho00TJ5B1mBM3rJkqiU46lgjAsicxsGrR+eV TrzWIipaMKqSBiSXW7KIIkYAmAw1n2ICg4vhTdWmhDi9a2pWdGOLBvHSeyubIYVr5SWH j6JriLCIhAuPLfzD0vVO7MDtD1cof69XBcvgHe377qGbDmdhXaUrWvq4Iy2sjsqVRxnK K3fBK4G2JS2qM2HmvS/3VDFKutSpRJxgjPoMGArVV6+ZN5Bnelt4Fk/wWt1F5aLRBux3 DrxwoOI7mdiGlWaCDi0zlW13rLFQSnv9WuXo+Vcm21BX/xbpqOQuvmTuz0IxwATpqn61 50LQ== X-Forwarded-Encrypted: i=1; AJvYcCU+EC9B85/ET/oM6MBoILYjR8lH0uJPOXRMPkPNw3P9GJ9OIO9H9w65Ft+Uf0+UjXW4Zv/JYHGVFbKcUftF7RLnsPGud70u6BiIgkfg X-Gm-Message-State: AOJu0YzB7VsrKSalFI6g2F8huLXJ5Lx6/IBbYb+5PuC0P/FnOjeTLUKT wQniEIIxJdeOvitohNqRSiTGarAYfcKAUieUA6poC2fNyQ777FmnToQT6lZHaSMBzRpmnJCv4hx DeU0E7euKSU5Y8WKNu1Mg9Z3xlc27XAs0Sm533aBBeU1g/jbxqApCZwXB1ECNaw== X-Received: by 2002:adf:e9c4:0:b0:343:dde1:2ef6 with SMTP id l4-20020adfe9c4000000b00343dde12ef6mr1522665wrn.27.1712309078251; Fri, 05 Apr 2024 02:24:38 -0700 (PDT) X-Received: by 2002:adf:e9c4:0:b0:343:dde1:2ef6 with SMTP id l4-20020adfe9c4000000b00343dde12ef6mr1522634wrn.27.1712309077765; Fri, 05 Apr 2024 02:24:37 -0700 (PDT) Received: from ?IPV6:2003:cb:c74b:5500:e1f8:a310:8fa3:4ec1? (p200300cbc74b5500e1f8a3108fa34ec1.dip0.t-ipconnect.de. [2003:cb:c74b:5500:e1f8:a310:8fa3:4ec1]) by smtp.gmail.com with ESMTPSA id f11-20020a5d568b000000b00343c9ce4b50sm1559079wrv.53.2024.04.05.02.24.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Apr 2024 02:24:37 -0700 (PDT) Message-ID: <7d5b2f03-dc36-477d-8d5c-4eb8d45db398@redhat.com> Date: Fri, 5 Apr 2024 11:24:36 +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 v5 2/6] mm: swap: free_swap_and_cache_nr() as batched free_swap_and_cache() To: Ryan Roberts , Zi Yan Cc: Andrew Morton , Matthew Wilcox , Huang Ying , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Chris Li , Lance Yang , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240327144537.4165578-1-ryan.roberts@arm.com> <20240327144537.4165578-3-ryan.roberts@arm.com> <4020c532-d20d-4624-8ea6-607de423396c@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+5qaSr0ID2sz5jtBLRb15RMre27E1Impa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PHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+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: <4020c532-d20d-4624-8ea6-607de423396c@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 03.04.24 09:21, Ryan Roberts wrote: > On 03/04/2024 01:30, Zi Yan wrote: >> On 27 Mar 2024, at 10:45, Ryan Roberts wrote: >> >>> Now that we no longer have a convenient flag in the cluster to determine >>> if a folio is large, free_swap_and_cache() will take a reference and >>> lock a large folio much more often, which could lead to contention and >>> (e.g.) failure to split large folios, etc. >>> >>> Let's solve that problem by batch freeing swap and cache with a new >>> function, free_swap_and_cache_nr(), to free a contiguous range of swap >>> entries together. This allows us to first drop a reference to each swap >>> slot before we try to release the cache folio. This means we only try to >>> release the folio once, only taking the reference and lock once - much >>> better than the previous 512 times for the 2M THP case. >>> >>> Contiguous swap entries are gathered in zap_pte_range() and >>> madvise_free_pte_range() in a similar way to how present ptes are >>> already gathered in zap_pte_range(). >>> >>> While we are at it, let's simplify by converting the return type of both >>> functions to void. The return value was used only by zap_pte_range() to >>> print a bad pte, and was ignored by everyone else, so the extra >>> reporting wasn't exactly guaranteed. We will still get the warning with >>> most of the information from get_swap_device(). With the batch version, >>> we wouldn't know which pte was bad anyway so could print the wrong one. >>> >>> Signed-off-by: Ryan Roberts >>> --- >>> include/linux/pgtable.h | 28 +++++++++++++++ >>> include/linux/swap.h | 12 +++++-- >>> mm/internal.h | 48 +++++++++++++++++++++++++ >>> mm/madvise.c | 12 ++++--- >>> mm/memory.c | 13 +++---- >>> mm/swapfile.c | 78 ++++++++++++++++++++++++++++++----------- >>> 6 files changed, 157 insertions(+), 34 deletions(-) >>> >>> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h >>> index 09c85c7bf9c2..8185939df1e8 100644 >>> --- a/include/linux/pgtable.h >>> +++ b/include/linux/pgtable.h >>> @@ -708,6 +708,34 @@ static inline void pte_clear_not_present_full(struct mm_struct *mm, >>> } >>> #endif >>> >>> +#ifndef clear_not_present_full_ptes >>> +/** >>> + * clear_not_present_full_ptes - Clear consecutive not present PTEs. >>> + * @mm: Address space the ptes represent. >>> + * @addr: Address of the first pte. >>> + * @ptep: Page table pointer for the first entry. >>> + * @nr: Number of entries to clear. >>> + * @full: Whether we are clearing a full mm. >>> + * >>> + * May be overridden by the architecture; otherwise, implemented as a simple >>> + * loop over pte_clear_not_present_full(). >>> + * >>> + * Context: The caller holds the page table lock. The PTEs are all not present. >>> + * The PTEs are all in the same PMD. >>> + */ >>> +static inline void clear_not_present_full_ptes(struct mm_struct *mm, >>> + unsigned long addr, pte_t *ptep, unsigned int nr, int full) >>> +{ >>> + for (;;) { >>> + pte_clear_not_present_full(mm, addr, ptep, full); >>> + if (--nr == 0) >>> + break; >>> + ptep++; >>> + addr += PAGE_SIZE; >>> + } >>> +} >>> +#endif >>> + >> >> Would the code below be better? >> >> for (i = 0; i < nr; i++, ptep++, addr += PAGE_SIZE) >> pte_clear_not_present_full(mm, addr, ptep, full); > > I certainly agree that this is cleaner and more standard. But I'm copying the > pattern used by the other batch helpers. I believe this pattern was first done > by Willy for set_ptes(), then continued by DavidH for wrprotect_ptes() and > clear_full_ptes(). > > I guess the benefit is that ptep and addr are only incremented if we are going > around the loop again. I'd rather continue to be consistent with those other > helpers. Yes please. I remember Willy found that variant to be most micro-optimized. -- Cheers, David / dhildenb