Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp729624ybg; Tue, 28 Jul 2020 18:03:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFB+mNluSAKuEWzyx1Kzuu2H8JnY1yO+DLlb+gxfyePlJzB7iETWQgGZnySq/sDkI4PvTU X-Received: by 2002:a17:906:3889:: with SMTP id q9mr29727424ejd.318.1595984613440; Tue, 28 Jul 2020 18:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595984613; cv=none; d=google.com; s=arc-20160816; b=lZWDGJLjD7XE1SaNf8vU+26UUrWfRIyouUq1quMEDWwAMUXv2NYIlwE8WxsINCh50x nDZza5te3S632kLOHX8X1jpMRzLhjchLvm/OMItMM/w0Bt9ihebpsKRi2naBxRFDGbiS slY/HCM1JbvlWu3AmBwSoJnANwYAQgB5aPSLySuZnBvBG7Qr/NcoZiqupUuKs8dHApan S9lmnLxK4petxpUY2xYolCx/YsFuCmA/8czT72ACqodB6OrRKdhXKc7AdSjMZSpah9Jp W3Ul0g7NN1sWPolqF5VbxC3l9h1nVd3PKeKcnlSRft/qKYoshUfDpSPyAhekeURk69lK 52Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=D/78RuBtCxvUjysglz0JntY34ip0jiwKXe2BAN3jvtE=; b=vRswp2Zjb0Hl9TNgDUAZtkc0onDtLytcl0E8rSqOfakmYk3L7ThyeD3ieIMnj1x1uH yYXjNoFlHwg3XJIWYY+ZROR6upA5Cjw5KVpGF0wAasWdbAcdbQ8kQ3RMTBv6UIx1PrwL qW06b86jpt3GEvA/raVi98IWIfWMsKPUU7hdyFThU5rpOCvym+UhPp2+D/4QeQ4t2sOi AVUuGIsS0fHYBjrrMWrWBNc/4VaNKUarLzupiRrUycbodNulo6RxhIZd6nv+zLsv3To0 Z3+35MO3rkYOxMkFch+aAR33EmIvsR7ykISunROI5tmZ4OimM55TNBvfyzy+g1kuiiX0 OIIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a90si228656edf.486.2020.07.28.18.03.10; Tue, 28 Jul 2020 18:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730992AbgG2BAZ (ORCPT + 99 others); Tue, 28 Jul 2020 21:00:25 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:44492 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729867AbgG2BAZ (ORCPT ); Tue, 28 Jul 2020 21:00:25 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R561e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0U46Ptxs_1595984420; Received: from IT-FVFX43SYHV2H.lan(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U46Ptxs_1595984420) by smtp.aliyun-inc.com(127.0.0.1); Wed, 29 Jul 2020 09:00:21 +0800 Subject: Re: [PATCH v17 17/21] mm/lru: replace pgdat lru_lock with lruvec lock To: Alexander Duyck Cc: Andrew Morton , Mel Gorman , Tejun Heo , Hugh Dickins , Konstantin Khlebnikov , Daniel Jordan , Yang Shi , Matthew Wilcox , Johannes Weiner , kbuild test robot , linux-mm , LKML , cgroups@vger.kernel.org, Shakeel Butt , Joonsoo Kim , Wei Yang , "Kirill A. Shutemov" , Rong Chen , Michal Hocko , Vladimir Davydov References: <1595681998-19193-1-git-send-email-alex.shi@linux.alibaba.com> <1595681998-19193-18-git-send-email-alex.shi@linux.alibaba.com> From: Alex Shi Message-ID: <09aeced7-cc36-0c9a-d40b-451db9dc54cc@linux.alibaba.com> Date: Wed, 29 Jul 2020 09:00:06 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/7/28 下午10:54, Alexander Duyck 写道: > On Tue, Jul 28, 2020 at 4:20 AM Alex Shi wrote: >> >> >> >> 在 2020/7/28 上午7:34, Alexander Duyck 写道: >>>> @@ -1876,6 +1876,12 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, >>>> * list_add(&page->lru,) >>>> * list_add(&page->lru,) //corrupt >>>> */ >>>> + new_lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page)); >>>> + if (new_lruvec != lruvec) { >>>> + if (lruvec) >>>> + spin_unlock_irq(&lruvec->lru_lock); >>>> + lruvec = lock_page_lruvec_irq(page); >>>> + } >>>> SetPageLRU(page); >>>> >>>> if (unlikely(put_page_testzero(page))) { >>> I was going through the code of the entire patch set and I noticed >>> these changes in move_pages_to_lru. What is the reason for adding the >>> new_lruvec logic? My understanding is that we are moving the pages to >>> the lruvec provided are we not?If so why do we need to add code to get >>> a new lruvec? The code itself seems to stand out from the rest of the >>> patch as it is introducing new code instead of replacing existing >>> locking code, and it doesn't match up with the description of what >>> this function is supposed to do since it changes the lruvec. >> >> this new_lruvec is the replacement of removed line, as following code: >>>> - lruvec = mem_cgroup_page_lruvec(page, pgdat); >> This recheck is for the page move the root memcg, otherwise it cause the bug: > > Okay, now I see where the issue is. You moved this code so now it has > a different effect than it did before. You are relocking things before > you needed to. Don't forget that when you came into this function you > already had the lock. In addition the patch is broken as it currently > stands as you aren't using similar logic in the code just above this > addition if you encounter an evictable page. As a result this is > really difficult to review as there are subtle bugs here. Why you think its a bug? the relock only happens if locked lruvec is different. and unlock the old one. > > I suppose the correct fix is to get rid of this line, but it should > be placed everywhere the original function was calling > spin_lock_irq(). > > In addition I would consider changing the arguments/documentation for > move_pages_to_lru. You aren't moving the pages to lruvec, so there is > probably no need to pass that as an argument. Instead I would pass > pgdat since that isn't going to be moving and is the only thing you > actually derive based on the original lruvec. yes, The comments should be changed with the line was introduced from long ago. :) Anyway, I am wondering if it worth a v18 version resend? >