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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS 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 2E317C4363A for ; Sun, 25 Oct 2020 23:59:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6589E222EC for ; Sun, 25 Oct 2020 23:59:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="yUEW/1sO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6589E222EC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 71F506B005D; Sun, 25 Oct 2020 19:59:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A9056B0062; Sun, 25 Oct 2020 19:59:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 598616B0068; Sun, 25 Oct 2020 19:59:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id 29FBE6B005D for ; Sun, 25 Oct 2020 19:59:51 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9B38B181AC9CB for ; Sun, 25 Oct 2020 23:59:50 +0000 (UTC) X-FDA: 77412118140.19.sleet26_240efc22726f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 7868C1AD1B3 for ; Sun, 25 Oct 2020 23:59:50 +0000 (UTC) X-HE-Tag: sleet26_240efc22726f X-Filterd-Recvd-Size: 2840 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Sun, 25 Oct 2020 23:59:50 +0000 (UTC) Received: from X1 (nat-ab2241.sltdut.senawave.net [162.218.216.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C0085222C2; Sun, 25 Oct 2020 23:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603670388; bh=s5N81VOFO1h8dj2jSReD4M4MfMKhzgGKYPYRzQyMrfY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yUEW/1sOitovk18LFxO2fWxTGCZ56ljsl7C4phIC3jUscOtuiKnuMcBrlRKApL/+M goox1RUv5y7qdWaLEVLuosjsLwrpiUwmnvjVeZjC+ztq6lLLVnn36tzOIDI0xLoSel z2QlvVzDtlBqf3K9sCW+Lc8A1++1UkyKf6k3cei8= Date: Sun, 25 Oct 2020 16:59:48 -0700 From: Andrew Morton To: Miaohe Lin Cc: , , Hugh Dickins Subject: Re: [PATCH] mm/swap_state: Skip meaningless swap cache readahead when ra_info.win == 0 Message-Id: <20201025165948.bd4f59d127952b9979d5c61e@linux-foundation.org> In-Reply-To: <20201009133059.58407-1-linmiaohe@huawei.com> References: <20201009133059.58407-1-linmiaohe@huawei.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Fri, 9 Oct 2020 09:30:59 -0400 Miaohe Lin wrote: > swap_ra_info() may leave ra_info untouched in non_swap_entry() case as page > table lock is not held. In this case, we have ra_info.nr_pte == 0 and it is > meaningless to continue with swap cache readahead. Skip such ops by init > ra_info.win = 1. > > > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -839,7 +839,7 @@ static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask, > swp_entry_t entry; > unsigned int i; > bool page_allocated; > - struct vma_swap_readahead ra_info = {0,}; > + struct vma_swap_readahead ra_info = {1,}; > > swap_ra_info(vmf, &ra_info); > if (ra_info.win == 1) Looks right. But I think it would be better to fix this in swap_ra_info() - make it more consistent in its return state. Otherwise, let's modernify that struct initializer: --- a/mm/swap_state.c~mm-swap_state-skip-meaningless-swap-cache-readahead-when-ra_infowin-==-0-fix +++ a/mm/swap_state.c @@ -839,7 +839,9 @@ static struct page *swap_vma_readahead(s swp_entry_t entry; unsigned int i; bool page_allocated; - struct vma_swap_readahead ra_info = {1,}; + struct vma_swap_readahead ra_info = { + .win = 1, + }; swap_ra_info(vmf, &ra_info); if (ra_info.win == 1) _