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 DB2C4C433EF for ; Thu, 20 Jan 2022 14:15:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 529CE6B00A3; Thu, 20 Jan 2022 09:15:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48BF96B00A5; Thu, 20 Jan 2022 09:15:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 305646B00A6; Thu, 20 Jan 2022 09:15:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id 1B7866B00A3 for ; Thu, 20 Jan 2022 09:15:43 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CD53B181CBC2D for ; Thu, 20 Jan 2022 14:15:42 +0000 (UTC) X-FDA: 79050863724.27.E05195F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 1DF02160008 for ; Thu, 20 Jan 2022 14:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642688141; 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=jJTThzl0vEu1BwNs59h7KVuOikFGV1SLvWSO9PgVPwxy62cp7etbWGTz28ss9/JertUE4J 6f/KViml01ptYHT2e/TSHdyl+7NDogC6jUGot6RGWZrS+C355FRzSEao4h2NAh2xY8eMXz F4gyA3B+PYpYEm/bx8AozyCy3RyVBug= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441--fXBQTL9M5q2I0e13rdjlA-1; Thu, 20 Jan 2022 09:15:40 -0500 X-MC-Unique: -fXBQTL9M5q2I0e13rdjlA-1 Received: by mail-wm1-f70.google.com with SMTP id az10-20020a05600c600a00b0034d64b1203aso5579441wmb.4 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=lChQzz55FW0mNZ89HUnQTq06C7mCjlw30lp3DjdRvCgjzR+A2VEH/8gc+aNKwRUPWR 70mmJif2I6QBNYr5R06yDlrhTumpZKR5yu3uM2BjqFIuyMDp0CixWxRtET5AvtLQVrwy lo2rbcjKVPSUhnCnvrnSu0MNN6HORcPCVLIGhamrPaMEeEwYmVLKSwXl4af2g9mFDptg xZle/RFgYSksd6WCjWp75QzuIsJIC05b8I9BroF1BtTAMDKxWfo7zjmYjg/kb09Qt8l2 Y9KRzYGoKVthO23/REcXj7nQ9gos9Y8Yg5HrhzrDp0XbnJscHYTNsB55BUN4IDKZv6Q2 MXVg== X-Gm-Message-State: AOAM531hqm02/cduJHOrbSNKmDmdlITaTDD70FETKjMqd8s1212sunl3 vDF1vOJrGrWBvN40T4cnF0nlxfRQsxYE+ukfGws28xsG8YXMK7xFwnhqb8xYa1qZKfSHI8GsoFY 6Mbfd+j75wZw= X-Received: by 2002:a5d:47c2:: with SMTP id o2mr34803981wrc.632.1642688139144; Thu, 20 Jan 2022 06:15:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPwZ3koqXNPZsFK96gf9YtWGNPxY/0Ou3ZrfC1XR3G0x0Sq77s2w0+jl4nQXTyO6wEvSbYXg== 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 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: 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-Queue-Id: 1DF02160008 X-Stat-Signature: 8khwe5igbynf95urgx93fg14nhh4ykcj Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jJTThzl0; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf08.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam08 X-HE-Tag: 1642688141-435797 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: 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