Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1280880pxb; Fri, 21 Jan 2022 14:14:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMKcvjkE2R28xwt7W4Ya/W/yt0lCL9mmM4qq9wSObFuKCLMQ3Mn9XCw1MbqwIJsB9aEJbr X-Received: by 2002:a17:90b:1c8c:: with SMTP id oo12mr2648600pjb.148.1642803247906; Fri, 21 Jan 2022 14:14:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642803247; cv=none; d=google.com; s=arc-20160816; b=x1x34v88EtNwqAHtugxtEGwFBg4RKYktgXJeKcVzI8dEbgHy4Mkg1XWglTsTr0oCnZ sSezIq6PZP2GZRDA/xb1ac0+QaDB8sLyamxzVUNXlAYsG+/PS45wLf1LB15Oje7sV0X1 +lIZ+iup02G8dQPfbxtveI3nASYPRSzFo7U4NXqud4pTgCe0fey7zE23g3l4+cYzowRk 6i7T+qHu7I9Vk0kdg1w7URlisuPvEjh23sen20Z9ZziYvg7IYkii2m61r2tY2FcqE7Ky HPbpURrqQ5c3n+YtGKIZl78FERLc1I6O4ep6RwdHGFbrgJJLc740jUbU2Lnp+R5CTxtZ AEGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=XScZOTdHK9NR/qaohb7b7v22at67z4wlXzfCulfCEig=; b=k5POsYNSChD3YZUvxEcQeERBq7tszfsVFexLCXbnrFhRblzbOnilmi+i+CXOkzE5IJ a/18fusTIpz/m6vjvzzU/P+Q7XG5CKAPOfq2N5MJZ6AGh+5E9qv+cKvD9MA25h5dNjJO yPHIB0a3q+0DqHwJoG+v81sKgG5M9titEtL3dKUdRtSnTpPZiYRgsQDc276aAy+7aOlu pYGam+oJBDLuo53psiYC9Tq73I+l2mwHsOgjkZkeTkyhyMCbS/RhFoQqGnHejpfpw/BQ nSlZb6w8lm+M2CUjAHHwZmKMJbhh7w1PsaK/zMPDITJ1eWpvjl7x6g2JHNkk2S/Iiwq8 24GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GpJ4Lt/s"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si7292715pgo.442.2022.01.21.14.13.56; Fri, 21 Jan 2022 14:14:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="GpJ4Lt/s"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245504AbiATOPp (ORCPT + 99 others); Thu, 20 Jan 2022 09:15:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24438 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbiATOPn (ORCPT ); Thu, 20 Jan 2022 09:15:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642688143; 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=XScZOTdHK9NR/qaohb7b7v22at67z4wlXzfCulfCEig=; b=GpJ4Lt/sJigYkbqK54W9eJJ2iEkWDYOTNgIInIqxD9NVPBq53OjU3Yt7xZzelXRPh2HwEs LLdWrfXTmIJCVdujU7olV16AkWFQoiaS3U7UuuPGQC4DVKHecQeR2QgJ0LqO3sxOhsvJuA DM3TTBPE1Cry4n0EebmGGPtZzh+yH0Q= 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-2x83DMxcMCy4akKamitIIA-1; Thu, 20 Jan 2022 09:15:40 -0500 X-MC-Unique: 2x83DMxcMCy4akKamitIIA-1 Received: by mail-wm1-f69.google.com with SMTP id bg16-20020a05600c3c9000b0034bea12c043so6911783wmb.7 for ; Thu, 20 Jan 2022 06:15:40 -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=XScZOTdHK9NR/qaohb7b7v22at67z4wlXzfCulfCEig=; b=REV7WmSf61/shUyDSUfeRr4KAvIxXFeJFiuxwaZ9/rCSv3r6eyKj2a9riZErtDo5PF rcy79p8vw5eSUlwu3SZ2fTYqFVAXb5gn4zyVCBOqAo9O8Tpj+N8trKHu5BO3UogDwmOy XwtYG55dF0PlWkGz+DitTOcW1LlNfmSi/pks3kt7TpJDmFebBQcULav+/nxGYXVuGXYv wIquGQi2aTSKEl76zn2BjgsKCAAutLEkWt7l6MHJMr9CrhjSK/o/Z9DIBAHwx/xOqA8H /epHgoK798VIoDzBNr02dpPrGPwJmHOwnt8rgqBgZrOux6/50aYG9zZ/J/SFmPktTYQC Y0+w== X-Gm-Message-State: AOAM530WUNGvwYB69rkkOPqN5nvnW3p3VbCK+xcy4cvOAsxtBDhTQbjI vqr4ieybb/vYO/Y2waEfGf5R+DaVosfFtYTxxv95HsF2Y4vM96tBRiX3XoYhhlcsRfm1jksYXK3 jk570OH8zND51meFGdW5rIkIQ X-Received: by 2002:a5d:47c2:: with SMTP id o2mr34803975wrc.632.1642688139131; Thu, 20 Jan 2022 06:15:39 -0800 (PST) X-Received: by 2002:a5d:47c2:: with SMTP id o2mr34803954wrc.632.1642688138923; Thu, 20 Jan 2022 06:15:38 -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 y8sm3699696wrd.8.2022.01.20.06.15.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Jan 2022 06:15:38 -0800 (PST) Message-ID: <747ff31c-6c9e-df6c-f14d-c43aa1c77b4a@redhat.com> Date: Thu, 20 Jan 2022 15:15:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Content-Language: en-US To: "zhangliang (AG)" Cc: Andrew Morton , Linux-MM , Linux Kernel Mailing List , wangzhigang17@huawei.com, Matthew Wilcox , Linus Torvalds References: <20220113140318.11117-1-zhangliang5@huawei.com> <172ccfbb-7e24-db21-7d84-8c8d8c3805fd@redhat.com> <9cd7eee2-91fd-ddb8-e47d-e8585e5baa05@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] mm: reuse the unshared swapcache page in do_wp_page In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17.01.22 14:31, zhangliang (AG) wrote: > Sure, I will do that :) I'm polishing up / testing the patches and might send something out for discussion shortly. Just a note that on my branch was a version with a wrong condition that should have been fixed now. I am still thinking about PTE mapped THP. For these, we'll always have page_count() > 1, essentially corresponding to the number of still-mapped sub-pages. So if we end up with a R/O mapped part of a THP, we'll always have to COW and cannot reuse ever, although it's really just a single process mapping the THP via PTEs. One approach would be to scan the currently locked page table for entries mapping this same page. If page_count() corresponds to that value, we know that only we are mapping the THP and there are no additional references. That would be a special case if we find an anon THP in do_wp_page(). Hm. -- Thanks, David / dhildenb