From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FA56C433EF for ; Thu, 20 Jan 2022 16:35:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7E3D6B0080; Thu, 20 Jan 2022 11:35:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E29CB6B009C; Thu, 20 Jan 2022 11:35:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF1EE6B009D; Thu, 20 Jan 2022 11:35:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id BBF856B0080 for ; Thu, 20 Jan 2022 11:35:29 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 85ACB8910B for ; Thu, 20 Jan 2022 16:35:29 +0000 (UTC) X-FDA: 79051215978.09.5474E11 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 0BF5F180021 for ; Thu, 20 Jan 2022 16:35:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642696528; 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; bh=7Cv4ecf7GNT/p9vmHS5xcSabCvV+bpl0vkADyXi+gD8=; b=axAwRR71h3oVaijXa+gCP/pcND04BYJX5zlFZh6ZsPU2OLz2c9aBc8M+wDK1zZ1z7gF5Sr pOatX2ktKLW/6kx7Gyr0EQd0+UixvC7N6HOSGHkQtiMVljv6OpWiSG405YbJbo55RNEvOa mpldy/5Sa+OeZg8BzsT5Pw5+wsyo9ys= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-j_UE5uY4NJmBUzHjYXzWSA-1; Thu, 20 Jan 2022 11:35:27 -0500 X-MC-Unique: j_UE5uY4NJmBUzHjYXzWSA-1 Received: by mail-wm1-f72.google.com with SMTP id l16-20020a1c7910000000b0034e4206ecb7so313791wme.7 for ; Thu, 20 Jan 2022 08:35:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=7Cv4ecf7GNT/p9vmHS5xcSabCvV+bpl0vkADyXi+gD8=; b=CF/8FuGq+rJnyIcnPYo2/oXymt8D7vFeM014BjNdOd8mB0E2U3dBFN95dDoyxO0KOe YJrpQAH1dTNVl0p53aoi3XmxwoOu9HrweSNmpU9cC2Cof9f176RQJCLYLy2HaMbezr6e FyedbZGW56dQXZ0KSs937sgG1115jZOUNlTt5tP0oNggO8NirZpEtXUkIuyux20myirs TlotUoBd11JeyKWeSurXPq3eX60vuLmBQHmDWPr+b4b6o7ezNhyJIK76/Yl5mSoszeM9 cH/Xj/0c9dItHps8oCOfeXh84SjhcjPk0GX0LUzfdvnfAOsJLPyhF4XqcOA/EMunrfby kv7g== X-Gm-Message-State: AOAM531jJOPVbiR1sWulL29KAJsfFg4//g1pudYvgtUz7oaXVQmbL8Ze xGVvleSAr5C6NQW92NRMth1nvGagkg1RFWX4K4vFRye8Z5MXT22qhOYl8x4zJgWJAGbbz/o4/0j iWk9rV//WKNw= X-Received: by 2002:a05:600c:3843:: with SMTP id s3mr5749073wmr.150.1642696525979; Thu, 20 Jan 2022 08:35:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMb3IqTVFLfQdg4IWw3BqbA+NKZnfLxu9CZU6PoSYNSOuBGcrB/a08RW5NoiZLqF3sZR88Jw== X-Received: by 2002:a05:600c:3843:: with SMTP id s3mr5749054wmr.150.1642696525736; Thu, 20 Jan 2022 08:35:25 -0800 (PST) Received: from ?IPV6:2003:cb:c70e:5800:eeb:dae2:b1c0:f5d1? (p200300cbc70e58000eebdae2b1c0f5d1.dip0.t-ipconnect.de. [2003:cb:c70e:5800:eeb:dae2:b1c0:f5d1]) by smtp.gmail.com with ESMTPSA id i17sm3055553wru.107.2022.01.20.08.35.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Jan 2022 08:35:25 -0800 (PST) Message-ID: <6ccfce39-d022-0c85-cfee-3070d9dfc9a1@redhat.com> Date: Thu, 20 Jan 2022 17:35:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 To: Matthew Wilcox Cc: "zhangliang (AG)" , Andrew Morton , Linux-MM , Linux Kernel Mailing List , wangzhigang17@huawei.com, Linus Torvalds References: <9cd7eee2-91fd-ddb8-e47d-e8585e5baa05@redhat.com> <747ff31c-6c9e-df6c-f14d-c43aa1c77b4a@redhat.com> <759f9bc8-0b10-7f0f-28a6-f292bed9053f@redhat.com> <88a8b1a3-232d-df9c-d7f6-0ea9f2dd4b36@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] mm: reuse the unshared swapcache page in do_wp_page In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 0BF5F180021 X-Stat-Signature: zgy6fq5ukh6hby6npsedofayansgd9e3 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=axAwRR71; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1642696528-524612 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: >> >> Sorry, I was less verbose because I was just sending out the >> patch+description to Linus' reply and was assuming you're going to read >> it anyways ;) > > This reply arrived before your reply to Linus ;-) Anyway ... Yes, I could just have added that I'm going to reply with the patch to Linus after Linus' mail flew in and I made up my mind how to proceed, that would have been nicer :) > >> Yes, I'm speaking about exactly that fallback path. > > OK, so in that fallback path, we're already determined the THP has > more than one reference to it (ok, maybe that extra reference was > temporary and now gone), but we've already split the PMD down into Yes, any extra references or concurrent writeback. Swapcache was once example that my patch hopefully handles properly. > PTEs, and COWed one of the other pages that was in the THP. If > anything, we should be more aggressive about COWing the remaining > pages in the THP, not looking for reasons why we might be able to > avoid COWing this particular page. At that point in time we didn't COW yet, we only PTE-mapped the THP, but yes, once we reach do_wp_page() we will always COW, even if there are no additional references anymore. Ideas I had what we could do once we're in do_cow_page() and we spot that we do have a PTE-mapped THP: * Count the mappings in the process page table and use that as baseline (instead of 1). Would fail if there are additional references. * Try to split the compound page immediately. Will also fail if there are additional references. COWing more extremely sounds like an interesting idea to free up the compound page after we fragmented it -- which will succeed once additional references are gone. -- Thanks, David / dhildenb