Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp551075rdb; Thu, 1 Feb 2024 17:25:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxh1FgDgTkROaciltYWx8xYRpRmPLAmsCrNlA05p1chpE/NGvnlU0m3TdjR5lLG7qDyxDi X-Received: by 2002:a05:620a:4512:b0:783:8b27:46f with SMTP id t18-20020a05620a451200b007838b27046fmr1025567qkp.31.1706837138478; Thu, 01 Feb 2024 17:25:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706837138; cv=pass; d=google.com; s=arc-20160816; b=EqkQnUR4Z6nQ8mEUacVWr3em5e8VsTpIU5Yhs0l5aez7GdhAVyiEG63vZxNWWeV3Jy vNC385QAHRl8C12mK4bUqKTkPKrqEbjT3+NL2FvjK7hDzxYSvqcJp9x1fe0rqqqYVFoR oiFDzVw+RuSp1TqzfLAOOfOtHhRPpOifgMEsHv39KPl8y+ZWYSWIc+obW5mpUxCIlY5H O8v/f4WppYIOealmyrQPvyOXrpo0PIoQCM/c+D/F0iLipgaBf7Qq6tPZLv/cGgJ2FRGL jxXEf11ukMHfWMUG1TP5r8tx9LQCUXcpysrfcyQGK/NEC8XmuGpcQaxyrIjuogLQStnk yTxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :cc:references:to:subject; bh=UVdQiJ60gHbmO93Db9K/4BPPX7/dsycsTaxf9J1S37c=; fh=PIpiBA8YEd227gbw9B4ghZlbD29xtzGT8C5NnnGDKwo=; b=kmlJ0ipShV0urpoN066+8gcYjzkpvd3UgdUrsOnOI8n82bx73HCcnmXM1cIUoC2Xn2 Xd693WoSjO3cjAwKtuHZYKVQBicRInTSeXLrodIMli/G7wabf0dtxQPs1epWLgZtCcNj aTz4amXQL13ZPJ5qieWsVcRlR1HfQVV9Sd44yccnBO1GGBMnUU6FMAo5nL79E+fZdG2U YrfG2dlds14EAdrCx9R1DbTKllhfwT/qma67u1AqdI94kmFrZSt4Yt9IeSz8KlJ8EyVt l2L1qm+y4xKu7kTOy2+Ff+m1BbNiQte/JofhQPgHRWUzhU2xCqnPQJw4lDtLeRZ99aR0 nK3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-49061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=1; AJvYcCWpkatfx3tnnxYZPe/QLsSlJs0cOq8eDZuDP0vWaBtT0OoSXKCGWIGon4lUJU24f8uwMjHgR6uYi7myC9L5knjiy/sjCque7HRPtSbBNg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h8-20020a05620a244800b0078437fe83a0si1001073qkn.739.2024.02.01.17.25.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 17:25:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-49061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3E1C11C24B8E for ; Fri, 2 Feb 2024 01:25:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4539C2CD; Fri, 2 Feb 2024 01:25:21 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02F69BE59; Fri, 2 Feb 2024 01:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706837121; cv=none; b=YOY1CZ6ScwokZFqICPM/T5HIJoCItIoEpQ0GUpEsC7VMZi664ITB5SkylID3NLG55nQB1aCjKPUYkFG3HfgcBSf4bdUxYeofVPzfRn3y0Mb4E7nQoGBzkwhISvm7uLPgyeUZMLVg/FDcrhyzGadbpc/GY6pMARfTlFmPNN3EX8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706837121; c=relaxed/simple; bh=9pXzTZRahveJlD2529M3LyLuJv0HB2sVEZBmB7s4/Xk=; h=Subject:To:References:CC:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=MZFJDWfTexA3wjoJnAy+zPr5GqmYPve8fkcZH5F6/ANK+QjwBk9j247hw5297QVLoLdinzlXQykNNSpljfNZvRAP+UbHotlYqm5IG4piIcdnTA9Shb4OxNzDiATjU/9/kCJ0IYypGXcIjSt0+l3xYo4eWdOqwIaj6dwe9tWqyEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TQyjV0rxwz1xn6M; Fri, 2 Feb 2024 09:24:14 +0800 (CST) Received: from dggpemd200004.china.huawei.com (unknown [7.185.36.141]) by mail.maildlp.com (Postfix) with ESMTPS id CC7AC140384; Fri, 2 Feb 2024 09:25:15 +0800 (CST) Received: from [10.174.179.24] (10.174.179.24) by dggpemd200004.china.huawei.com (7.185.36.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Fri, 2 Feb 2024 09:25:15 +0800 Subject: Re: [PATCH 2/2] mm/readahead: limit sync readahead while too many active refault To: Jan Kara References: <20240201100835.1626685-1-liushixin2@huawei.com> <20240201100835.1626685-3-liushixin2@huawei.com> <20240201093749.ll7uzgt7ixy7kkhw@quack3> <20240201173130.frpaqpy7iyzias5j@quack3> CC: Alexander Viro , Christian Brauner , Matthew Wilcox , Andrew Morton , , , From: Liu Shixin Message-ID: Date: Fri, 2 Feb 2024 09:25:14 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240201173130.frpaqpy7iyzias5j@quack3> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemd200004.china.huawei.com (7.185.36.141) On 2024/2/2 1:31, Jan Kara wrote: > On Thu 01-02-24 18:41:30, Liu Shixin wrote: >> On 2024/2/1 17:37, Jan Kara wrote: >>> On Thu 01-02-24 18:08:35, Liu Shixin wrote: >>>> When the pagefault is not for write and the refault distance is close, >>>> the page will be activated directly. If there are too many such pages in >>>> a file, that means the pages may be reclaimed immediately. >>>> In such situation, there is no positive effect to read-ahead since it will >>>> only waste IO. So collect the number of such pages and when the number is >>>> too large, stop bothering with read-ahead for a while until it decreased >>>> automatically. >>>> >>>> Define 'too large' as 10000 experientially, which can solves the problem >>>> and does not affect by the occasional active refault. >>>> >>>> Signed-off-by: Liu Shixin >>> So I'm not convinced this new logic is needed. We already have >>> ra->mmap_miss which gets incremented when a page fault has to read the page >>> (and decremented when a page fault found the page already in cache). This >>> should already work to detect trashing as well, shouldn't it? If it does >>> not, why? >>> >>> Honza >> ra->mmap_miss doesn't help, it increased only one in do_sync_mmap_readahead() >> and then decreased one for every page in filemap_map_pages(). So in this scenario, >> it can't exceed MMAP_LOTSAMISS. > I see, OK. But that's a (longstanding) bug in how mmap_miss is handled. Can > you please test whether attached patches fix the trashing for you? At least > now I can see mmap_miss properly increments when we are hitting uncached > pages... Thanks! > > Honza Thanks for the patch, I will test it. >