Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp329018lqc; Thu, 7 Mar 2024 20:57:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXFnaBCypcELeWXPMuj6+kqq/b8Huuwbl1+Ie3SNpDmKwz2HwR6SPaTT0MzCPXBL3m7Mg5zaaZHuC5BukJWe0Ldv/+zADgI47h5Fsjpfw== X-Google-Smtp-Source: AGHT+IG6NwUPH3SojQIwfOhAUR4h6yArT7DQgDQXYj2OfaN8fulGSZ1xoXrl3+/pCuPtvFsz+fhN X-Received: by 2002:a54:4483:0:b0:3c2:214a:c0bc with SMTP id v3-20020a544483000000b003c2214ac0bcmr5615120oiv.39.1709873825482; Thu, 07 Mar 2024 20:57:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709873825; cv=pass; d=google.com; s=arc-20160816; b=Xv9RWj69HHAjW9vqO/sVkXHa0a2mF/SlDYhPGEuFTwUOcJwl6x6wffFN1C+GHUP8cF GuRixQpoY72VXtozYrZ493IpcATyfixSJRAJSlvJAYoP2KEYcXPg8NPeQPQy553MxHlr x3WYypSwr6NTSlYDsEDrXb3hNERow96DHiAnrXIMjrny0PjV6XZkQaaoIOXIAK+yIa27 J+C5CYJer9XfXzldDRJFadFGzJJyeEZ+1X3xrO33AXFlR2WRXJKoi3J1cIWP8X+18KbV jnDHWSfz2YiB6qi4owEQF7TfWHomWa6xsUfF85jq5Om07UX6HQOrlpNrtRcsCrMtI4EN kw9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FpAzxbK4c61fYlxUcROxFoZVfcD/2ddhJfA1Sk/q7Y8=; fh=dcBf3Z4XSEP7g6CHYclinjp2slyJJCxv5guy50U64Xw=; b=uMaexTFrq08o4pemh7t5DB/CMzLBkMHCQ22Su04ctQ+0e+Guu31soDpCf7tLWXY0tf K6ucz65zJJrVs+LVFam22hoTuauczCruLUZywlm3pp2gNxvgW34cWYm1ixyrQANuDcac 7x6V59zKKCuC3ruwDXIRYh9aNtOndPHM42/eoVHWv4FPg5VmsWT3fTbkRJNaaZ7kr2UH 312b2ohBXIEwCmYBHl15G87ihQTGJ42gU/QmXNxIl8rg0KlW2z0yP88xzZ6yxltMyNMQ 94DcnHuuj37cBiv0rGLM+b9V1xhYY4NfKR5tpnnlQeJWZ9Cj6oSa2gnoHzdYoxugoPnt jJDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="T4CRU/Hk"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-96512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96512-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b10-20020a63d30a000000b005dc41265c15si15792832pgg.658.2024.03.07.20.57.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 20:57:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="T4CRU/Hk"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-96512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96512-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6BD3FB21A56 for ; Fri, 8 Mar 2024 04:57:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E61082E62E; Fri, 8 Mar 2024 04:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="T4CRU/Hk" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 33B721CFB2 for ; Fri, 8 Mar 2024 04:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709873813; cv=none; b=seXkI+W0bvCkAvYnQ1btB+NyBI2ylVJF/x6RZNyYEJM3DDaXvVRLfVUPRJFQYYSj8+DNUMKNySUUUwhLPmSbGiZRhtsZzWxlgSvWKiEMbWrzyWUbhotxtnZnclOVwzEde8JAkHxMuOHTxap+RThJdfnBNRmdARipye5szC7qO9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709873813; c=relaxed/simple; bh=3wClNudqM5whTwW4VLZGzH3ML+XgAjUTBLrIe1VPYrc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UBXOqQYMx24FYDIfbzlnpI8m7XYLx9ROFCcJksZpORxpcc3qgDdj7Eysq3NgE4XrAEEPddsIdGm3zJzpFgnBkPbZupIDGrB6W1Y3SyNiymeYvrFGNDaiedWo6MrLwSZcHULtZ1wyWFUmUUV7uAfG/1PE5zRt983O6l5UW5QErds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=T4CRU/Hk; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FpAzxbK4c61fYlxUcROxFoZVfcD/2ddhJfA1Sk/q7Y8=; b=T4CRU/HkppN1YdmOI1o79jRpwo 8lkIaoPUIavYephzeW+DqvejzhfiF5EF43G7i1t+h2z6ka+Lc96wTIyzWCa1CAPous7m/tXQ5J9lq BrjbbugCuMC+/GkVcdo3JQVAKYK1PNFdvf2rEWumSzjWTXa3cS+vY7wQpUok92Jbq2iiEbJSoKg6J UeJL2RBHTm2cPMzZOA+rUA6JqjFN42qIoG//W0xDFuc9pc4pzrpxNsbLEBg43dOwHIS+DPR3WI1wB 6abFKCRW0cO9s63i+/7r9pGbf0ihv/z8l3hnYmhcYFQzbtGGza9hraeK4VitikeroWg3L75ENcxUg 0bqU2JqA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1riSHm-0000000Akts-1dMG; Fri, 08 Mar 2024 04:56:46 +0000 Date: Fri, 8 Mar 2024 04:56:46 +0000 From: Matthew Wilcox To: lipeifeng@oppo.com Cc: 21cnbao@gmail.com, akpm@linux-foundation.org, david@redhat.com, osalvador@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Minchan Kim Subject: Re: [PATCH v2 0/2] reclaim contended folios asynchronously instead of promoting them Message-ID: References: <20240308031126.750-1-lipeifeng@oppo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240308031126.750-1-lipeifeng@oppo.com> On Fri, Mar 08, 2024 at 11:11:24AM +0800, lipeifeng@oppo.com wrote: > Commit 6d4675e60135 ("mm: don't be stuck to rmap lock on reclaim path") > prevents the reclaim path from becoming stuck on the rmap lock. However, > it reinserts those folios at the head of the LRU during shrink_folio_list, > even if those folios are very cold. This seems like a lot of new code. Did you consider something simpler like this? Also, this is Minchan's patch you're complaining about. Add him to the cc. +++ b/mm/vmscan.c @@ -817,6 +817,7 @@ enum folio_references { FOLIOREF_RECLAIM, FOLIOREF_RECLAIM_CLEAN, FOLIOREF_KEEP, + FOLIOREF_RESCAN, FOLIOREF_ACTIVATE, }; @@ -837,9 +838,9 @@ static enum folio_references folio_check_references(struct folio *folio, if (vm_flags & VM_LOCKED) return FOLIOREF_ACTIVATE; - /* rmap lock contention: rotate */ + /* rmap lock contention: keep at the tail */ if (referenced_ptes == -1) - return FOLIOREF_KEEP; + return FOLIOREF_RESCAN; if (referenced_ptes) { /* @@ -1164,6 +1165,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, case FOLIOREF_ACTIVATE: goto activate_locked; case FOLIOREF_KEEP: + case FOLIOREF_RESCAN: stat->nr_ref_keep += nr_pages; goto keep_locked; case FOLIOREF_RECLAIM: @@ -1446,7 +1448,10 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, keep_locked: folio_unlock(folio); keep: - list_add(&folio->lru, &ret_folios); + if (references == FOLIOREF_RESCAN) + list_add(&folio->lru, &rescan_folios); + else + list_add(&folio->lru, &ret_folios); VM_BUG_ON_FOLIO(folio_test_lru(folio) || folio_test_unevictable(folio), folio); }