Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6671170iob; Wed, 11 May 2022 02:48:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL9lWoLsBvTs1xJY67g8Uxmytk79pmkH0FDdr+pRXgUCw0ELRmZaOPBzAxkOTfr+Z/nMLi X-Received: by 2002:a05:6a00:16d2:b0:512:c652:a2f7 with SMTP id l18-20020a056a0016d200b00512c652a2f7mr394518pfc.9.1652262494934; Wed, 11 May 2022 02:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652262494; cv=none; d=google.com; s=arc-20160816; b=KIFk5INfoLnd6LSWwdb9DIhe+30NQkewmPCYKp2F2HYdSXnbG3hG9cGuqnL3UUNf+e wXCfS4GL231XLPiwgpjyN/4Hv0DD4GevkDJyBgFr9KDHQqnVaLnyor0RJ8Zys0PQb7ay fCllOE/dylyz9W9R/BFFqNeZ1XBRebUob36xMcVnH9xYBFPd3G+NJFo7em6h3fiXVP7O PKGBo4bLMXXZtxqplxk4wSMTge2h2Q5s2cGGj2VqP2koi4bYuPJwM/ztfSneTcRnPMOE KahxeywhqMgD+aWcapU3y0yufpO5pJKrktqOGt/O6Jf1DqqY/YS/yh6OfRa1DXYRXfoN qGSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j6VxUo8QQgucktTahfGjMnSHx49seR2VNE5VfPNoqpw=; b=HdKwuB7oihsMmaBqSnxmksa6BcORvtEGppqFenGf6wFRWk94DFFXvvrbiBvwC1ihIL jfsfdcl3cdTER+gVOzWfLNDxBGOWKOf1ZqKR75TYtrorRvjXBYrWWErCYvVu4l/TcWY4 M5qM/hmos/r/n0yEmrjabFSD2Ch+982CKEnlyiAP0AHaRCtJmR/1Q7XaftQotElMrgUb qTPq+OCN8PDsJaCQBAWAXqXKYQrtYFzcHhNCYs8+YjmGGOZqxXSs5GQCRt6s3LEZ76Sp sZ1frFZDNdtaXy54l9Fc+FBedBWgsynBz2vHdBZFa3zLS2Zdw9JEzHvs8mHjR+ymb7TB g92Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=AZ8FOeLY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020aa79255000000b005061dab8a95si1786821pfp.121.2022.05.11.02.47.59; Wed, 11 May 2022 02:48:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=AZ8FOeLY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241309AbiEJSVh (ORCPT + 99 others); Tue, 10 May 2022 14:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348780AbiEJSVF (ORCPT ); Tue, 10 May 2022 14:21:05 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7B3396B0 for ; Tue, 10 May 2022 11:17:05 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id o11so14142674qtp.13 for ; Tue, 10 May 2022 11:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=j6VxUo8QQgucktTahfGjMnSHx49seR2VNE5VfPNoqpw=; b=AZ8FOeLYs0Ou66qeac0W+jy0+5ZasZRmYmeiVyej+xT3ycHzEWtgp+hRatbjGISWoZ W3uLF/kp7vL+Sfjeyug2wWia4wkxMJvWRv87HCIw7tK33gc73vCgsl/NtSOtWmjbZyob VBcwki3iHmsZPoaIRE5YJJJkKpfJ7VrCl7Xr+i+shLyDlFCMEAqJXnYlrvDCBsrkFhVi rJEa0btzLKYM4zLEWhRLDZbDvaVu5OUwKxt8iRZ0c7j/9qPSVqQUBnWRv6rKzE+5OcJN uZLdqJFn2knl07MWB9d3MNPa0aQA7Twpxp9KINsG5OxFhgdMsDBkxmU0KipHE89NfL9Z aRvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=j6VxUo8QQgucktTahfGjMnSHx49seR2VNE5VfPNoqpw=; b=wcFE5ydFg3+7pYk9FiA+Dy0LDzbStoBtDxi/xBJJalJ3xk0NkazcrnJFXqUvZxn5Rf 7w1tHRvuRhcBERqIm/YSfCexMWbKyT1/fXzBJkVQevzxz4rQsZqfQqgareBunMKEKQBf nk9T3W7j1m/p53L1052S9YQ6kne7EgDX4Y/Fp7O88vFzRydAD5InNFJNyh7AOn0zJLNR TmfD0LX49vAFozvozSUvrJkKK3qASOLOkyMQvWiLb4mkidsAC8WeHxdEM4Fh119mleGh NwpdYEbmPT9l0lFCMR4xxdzXyQ2Ewjyd3CH4n0iNhZE8b6op1BC/hKhDKXki2UawGwM0 OZtg== X-Gm-Message-State: AOAM531zKx3xDiUogQbXcf+rPiCd69P+pMWZyW0O4bNdjDYdEdJpR4Zn 3R2g8qoxpx9PVkGsBvrqhrRnJg== X-Received: by 2002:ac8:5745:0:b0:2f3:e231:bc12 with SMTP id 5-20020ac85745000000b002f3e231bc12mr4843122qtx.291.1652206625133; Tue, 10 May 2022 11:17:05 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:14fe]) by smtp.gmail.com with ESMTPSA id k6-20020ac81406000000b002f39b99f69fsm9434981qtj.57.2022.05.10.11.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 11:17:04 -0700 (PDT) Date: Tue, 10 May 2022 14:16:07 -0400 From: Johannes Weiner To: Minchan Kim Cc: Andrew Morton , LKML , linux-mm , Suren Baghdasaryan , Michal Hocko , John Dias , Tim Murray , Matthew Wilcox , Vladimir Davydov , Martin Liu Subject: Re: [PATCH v3] mm: don't be stuck to rmap lock on reclaim path Message-ID: References: <20220510171100.48500-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220510171100.48500-1-minchan@kernel.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Minchan, The patch looks reasonable to me, but one thing stands out: On Tue, May 10, 2022 at 10:11:00AM -0700, Minchan Kim wrote: > @@ -1391,6 +1391,10 @@ static enum page_references folio_check_references(struct folio *folio, > if (vm_flags & VM_LOCKED) > return PAGEREF_ACTIVATE; > > + /* page_referenced didn't work due to lock contention */ > + if (referenced_ptes == -1) > + return PAGEREF_KEEP; > + > if (referenced_ptes) { > /* > * All mapped folios start out with page table This means contended inactive pages get rotated. > @@ -2492,7 +2496,7 @@ static void shrink_active_list(unsigned long nr_to_scan, > } > > if (folio_referenced(folio, 0, sc->target_mem_cgroup, > - &vm_flags)) { > + &vm_flags) > 0) { > /* > * Identify referenced, file-backed active pages and > * give them one more trip around the active list. So This means contended active pages do NOT get rotated. It's a bit of an arbitrary choice what to do with reclaim candidates for which you can get no reference information, but staying consistent is likely a good idea. My preference would be to just rotate contended pages throughout rather than risk dropping the workingset on the floor. /* Referenced or rmap lock contention: rotate */ if (folio_referenced() != 0) { ... What do you think?