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 X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A7F8C433DB for ; Wed, 13 Jan 2021 05:24:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DEB0622B37 for ; Wed, 13 Jan 2021 05:24:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEB0622B37 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F05586B00B4; Wed, 13 Jan 2021 00:24:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB64E6B00B7; Wed, 13 Jan 2021 00:24:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCB706B00B9; Wed, 13 Jan 2021 00:24:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id C7A306B00B4 for ; Wed, 13 Jan 2021 00:24:19 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9291D180AD81F for ; Wed, 13 Jan 2021 05:24:19 +0000 (UTC) X-FDA: 77699611038.23.fear94_4f02fbf2751b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 750EE37604 for ; Wed, 13 Jan 2021 05:24:19 +0000 (UTC) X-HE-Tag: fear94_4f02fbf2751b X-Filterd-Recvd-Size: 4604 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 05:24:18 +0000 (UTC) Received: by mail-io1-f46.google.com with SMTP id e22so1777433iom.5 for ; Tue, 12 Jan 2021 21:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F/OA+LEep844St+cLlN9bVuByZKQc9ECoZJDuSzWDXM=; b=pM2UxjNfimjxWa+YA7Vc6k4xjRxRbAliS/VyfsvmN2KD+U4L9sFrImXRd5NSwWrYIF qixPKyw8S4nzL7HHDqBg0+zxsBrq7hBytISqZs6qOK/N3TwAWWoBcm1zzhDiyvFcsRbl T6guDKnfqBUORiWuBzAlAz7uXih5uvczPcqewlEFtu/66bwj3HF4ELC4o6eKplzA+nB2 R8n9/lDh+nt29C6ZgZxu1WYSs/N5LiJIHzpcAwYDytH/n31RMAX0ePUo/S60y+HTnEDO UJRjD/38h4Mkss3d/uMCuwVxtl6pCGgrYuVS7iTPBJqOxq4i6HdxYlGU6F8PgqM5MG8o oXow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F/OA+LEep844St+cLlN9bVuByZKQc9ECoZJDuSzWDXM=; b=rqm+7uYnrAnA+x3dvDM6uMsF18FDu0RffNJQQIlo/em1WVCoGyBWdmS6+UO+WVA45j 4DkGakjd92fwy8W5/hDyfUscJv2sPPEoZbgrQB9CWXL5m6JqkS25vK/FNsAZrqF3c3/s +Vd1Ia/ZQ+sZlJqA5SQU43mIi0vJxEn4gYfsJqXJuglzFOEcrEBr03Tgg1bhyCQyuxzq RXPW643twt7kN0/aDH5F8SXOvhx8Mhtfc3fNOYbm1hEv66T/xd2CsSRLduCwZ0FyN/Kk tgsMoJ5VIiUy2zOIs2PhnTg6arlXUhPn8chzsz3Bn25Hn2vYdPqe6k1dDTU/DkAIRUtK ADWA== X-Gm-Message-State: AOAM530G5QlgKvZXj3a3mpdzksHswtuebf1C8wb4hw4+Snw9CIdxJD0D pSl7zRSZ9/P/LhWizQDT3cCELM5jxNUr0C/CrCU= X-Google-Smtp-Source: ABdhPJyL0YYvYyzO8fms7Tt132zPWXgDIVrVPUF/0TpbLxbDoeyxjZ55FsZVk1YbvzSwgi0ALEDFidNoPecLUwiI8vE= X-Received: by 2002:a02:c7cb:: with SMTP id s11mr885489jao.94.1610515458507; Tue, 12 Jan 2021 21:24:18 -0800 (PST) MIME-Version: 1.0 References: <20210113024241.179113-1-ying.huang@intel.com> <20210113031142.GM35215@casper.infradead.org> In-Reply-To: <20210113031142.GM35215@casper.infradead.org> From: huang ying Date: Wed, 13 Jan 2021 13:24:07 +0800 Message-ID: Subject: Re: [PATCH] mm: Free unused swap cache page in write protection fault handler To: Matthew Wilcox Cc: Linus Torvalds , Huang Ying , Andrew Morton , Linux-MM , Linux Kernel Mailing List , Peter Xu , Hugh Dickins , Johannes Weiner , Mel Gorman , Rik van Riel , Andrea Arcangeli , Michal Hocko , Dave Hansen , Tim Chen Content-Type: text/plain; charset="UTF-8" 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 Wed, Jan 13, 2021 at 11:12 AM Matthew Wilcox wrote: > > On Wed, Jan 13, 2021 at 11:08:56AM +0800, huang ying wrote: > > On Wed, Jan 13, 2021 at 10:47 AM Linus Torvalds > > wrote: > > > > > > On Tue, Jan 12, 2021 at 6:43 PM Huang Ying wrote: > > > > > > > > So in this patch, at the end of wp_page_copy(), the old unused swap > > > > cache page will be tried to be freed. > > > > > > I'd much rather free it later when needed, rather than when you're in > > > a COW section. > > > > Unused swap cache isn't unused file cache. Nobody can reuse them > > directly before freeing them firstly. It will make COW a little > > faster via keeping them. But I think the overhead to free them isn't > > high. While keeping them in system will confuse users (users will > > expect file cache to use free memory, but not expect unused swap cache > > to use much free memory), make the swap space more fragmented, and add > > system overall overhead (scanning LRU list, etc.). > > Couldn't we just move it to the tail of the LRU list so it's reclaimed > first? Or is locking going to be a problem here? Yes. That's a way to reduce the disturbance to the page reclaiming. For LRU lock contention, is it sufficient to use another pagevec? Best Regards, Huang, Ying