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 F375BC433F5 for ; Fri, 21 Jan 2022 09:01:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E9CF6B00A9; Fri, 21 Jan 2022 04:01:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 899B06B00AB; Fri, 21 Jan 2022 04:01:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7615C6B00AC; Fri, 21 Jan 2022 04:01:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 681596B00A9 for ; Fri, 21 Jan 2022 04:01:23 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 28B2B181C8F32 for ; Fri, 21 Jan 2022 09:01:23 +0000 (UTC) X-FDA: 79053700446.11.F5C47BB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 8F9B540010 for ; Fri, 21 Jan 2022 09:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642755681; 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=DIBKgVb122cd+imTMSb5fkOXwRpek4LueWHbXO5Yzk4=; b=gOQrr5PEYkgz01qVufOjDpuUCavkqxSE2w896R3pXMDIH/MhtYfwBmulFDyUzPPYwqs7OM tPKURhcdXl3jH9USkHeLVhn4muN2ImqTfceIluC65J+nd8ZwjESJbSFdwQEc2ZRviqUHbN sWgRYpNIbWedJQ7lCa4TPenIosz6QEc= 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-437-5IWuq_cCPd-7CF_m06msXw-1; Fri, 21 Jan 2022 04:01:20 -0500 X-MC-Unique: 5IWuq_cCPd-7CF_m06msXw-1 Received: by mail-wm1-f69.google.com with SMTP id a3-20020a05600c348300b0034a0dfc86aaso9007329wmq.6 for ; Fri, 21 Jan 2022 01:01:20 -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:from:to:cc:references:organization:subject :in-reply-to:content-transfer-encoding; bh=DIBKgVb122cd+imTMSb5fkOXwRpek4LueWHbXO5Yzk4=; b=WkQjvvd9DRmktw9cvD5OzcG8pQlZKADtDrbr2BChtrFhU9YeWqS7CrpSbmulmLji8e 6K7u9qY2NvmR6vhxePKGg+sngXRkSouOFKdzr59r6KG9QNoc+X71yhS2CC6h6pdykHbG 1cVx/xtDdVpy73vj3JfrSphTWZLW9AvIZJ96OxqGp1XCPsq2VpxWmpP1QbPNH/WcM6MP HG1AcJCMB6bNdImsoPuZnx1kHncAQ82Z9jVznX1UuxaTY113+9PJmBsyRiCS8CdffI5E usmnUtmPYwIVUZvTB+WeDO9CbvlipD3f75OMM7eC4UkzKluAq8f/yo8aj8e/56CQVDtc bfsw== X-Gm-Message-State: AOAM533NkBg1CL+hGA9vf8NaADwz3E8QEhS4qGkOwHRNTsm9hvvSYrSl e9OYpDP3JnGDYfm/ec5Ouf93m0NcVcCOWb0uYRs43JhfpS3S8M7yDCyjZ06k1U5gxsdm4Rzs6Td SjCkBWjZazT4= X-Received: by 2002:a5d:6dac:: with SMTP id u12mr2946633wrs.466.1642755679212; Fri, 21 Jan 2022 01:01:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyivgjgWOHftgfSfkxXCdmFwXNsRs+FJ0mvbmGG0Gm5jybpEkQNhZQH7dacyAa8vHJ1oqAWrw== X-Received: by 2002:a5d:6dac:: with SMTP id u12mr2946609wrs.466.1642755678984; Fri, 21 Jan 2022 01:01:18 -0800 (PST) Received: from ?IPV6:2003:cb:c709:a200:adf9:611a:39a8:435a? (p200300cbc709a200adf9611a39a8435a.dip0.t-ipconnect.de. [2003:cb:c709:a200:adf9:611a:39a8:435a]) by smtp.gmail.com with ESMTPSA id l15sm9456888wmh.6.2022.01.21.01.01.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jan 2022 01:01:18 -0800 (PST) Message-ID: <03b0ed0c-51af-1e68-350c-19a3b38a6e48@redhat.com> Date: Fri, 21 Jan 2022 10:01:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 From: David Hildenbrand To: Nadav Amit Cc: Matthew Wilcox , "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> <8931808d-db61-0f06-ceb3-f48a83b1f74c@redhat.com> <6225EAFF-B323-4DC5-AC4C-885B29ED7261@gmail.com> <9071d5a8-ed2d-5cf5-5526-43fe7dd377ec@redhat.com> <42a9b72d-093e-c35c-f4b5-b321a666e67d@redhat.com> <288FB900-A688-4EDB-95C6-E63B6E0A15D1@gmail.com> <7a18f74f-9dc2-f23d-4f1c-c7a9217f8317@redhat.com> Organization: Red Hat Subject: Re: [PATCH] mm: reuse the unshared swapcache page in do_wp_page In-Reply-To: <7a18f74f-9dc2-f23d-4f1c-c7a9217f8317@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 X-Stat-Signature: 9wbuttws8e3snef9y7y6go1tfb4zi7co Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gOQrr5PE; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.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: rspam09 X-Rspamd-Queue-Id: 8F9B540010 X-HE-Tag: 1642755682-152422 Content-Transfer-Encoding: quoted-printable 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: >> >> I did hack something similar and it solved the problem, but I felt it = is >> a hack. If the thread is scheduled on another core, or if the write fa= ult >> is triggered by another thread it wouldn=E2=80=99t work. >=20 > Yes, it will not match easily. One question would be how often it would > help in practice and if it would be worth the price. >=20 I did some more testing and I have to admit that your reproducer is really good at finding corner cases. Assume we try to handle LRU as discussed ... what I get is a delta during the test: ./forceswap 2 100000 1 anon_wp_reuse 920 -> we were able to reuse anon_wp_copy_count 0 -> we failed the final page_count() =3D=3D 1 check anon_wp_copy_count_early 634 -> we failed the early page_count() check considering swapcache and lru anon_wp_copy_lock 1 -> we failed trylock anon_wp_copy_lru 19 -> we failed to clear the lru cache reference anon_wp_copy_writeback 99974 -> we failed to clear the swapcache reference due to concurrent writeback anon_wp_copy_swapcache 0 -> we failed to clear the swapcache reference for other reasons So, yeah, we mostly always hit writeback in forceswap.c. reuse_swap_page() would have been able to reuse the page if the swap backend would have supported concurrent writes during writeback (IIUC, zswap doesn't). But I think triggering that case that often really is an oddity about the test case. --=20 Thanks, David / dhildenb