Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3221815ybc; Mon, 25 Nov 2019 10:54:01 -0800 (PST) X-Google-Smtp-Source: APXvYqyYqdt7sVTh1TPTefdd1RKbGrpA3R8MPRn2H4L7fXzPo+tkUKN+CYHGjNmQT/y0vWGOIdkp X-Received: by 2002:a17:906:b797:: with SMTP id dt23mr12845606ejb.241.1574708041606; Mon, 25 Nov 2019 10:54:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574708041; cv=none; d=google.com; s=arc-20160816; b=IEFcyYBtSYU8vang9VbQqcW4qKZf4AK3aeWgqJhZAKVHZbr/+kMSuASutZkyfwzumS ppjBaCF/UxfES1tuaQJGX+HI5pgcGJ0CSiWMjZe/vdWREBEJovqXR2eNRWgy3QVXFDYW H3FJ0GWfce6f8+FbFYK1IPON1t3R8sNDLtH0YuEcOnRKLkm8D8i2dibsZjAAK4CvmmdN OLFd9UrHxQqdg71+uczxQoKN6JNjnZB06nBBhJ6yNHazGMVZBDy8jhtfUg88SeqeWaXV Zs28WWkLnpZ33rDQEfQnzizGBVlc2ZcaGr7IDXfMqfMSLmHvrR6G/d2ay4WuF7Xz2FbE nnxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ehtg0LDgFByK5WRliTFTt8kMCURVP50x4sdG0deprfY=; b=LDMA/q3fxfvM4rAZMY0dAyUtGCV4jqGc7IE43S5psrw1GO6vKe51gK4o6p2fXSRW9B 1sXcTipp6aMMgakrjGzGuMvMvfKO2GAxhZLBhXyAsQUF86gSZb25EInUGIWMoq3JPF26 zS2DvkvmYBfe5tYeu8FDip/iQJaAzQFbJ5UA+eL0eRb/y0FcCjOtg3j3dtjexqXKeZ7+ eKh8vmeoXsYkMiyjehnG7EsddI9tKoZvEGjV2dZiGq2XiNtRylt9Yv0zXS7/kVEk8deC M86p5sKomrGxTX4VZR1L6SYsGM1/C6qHHBa3F1BojWwmF25+ZuTs14sLf1FcVleIiQvY Hf+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MsGNoi87; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si6840236edn.266.2019.11.25.10.53.37; Mon, 25 Nov 2019 10:54:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MsGNoi87; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727386AbfKYR1k (ORCPT + 99 others); Mon, 25 Nov 2019 12:27:40 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:41602 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbfKYR1j (ORCPT ); Mon, 25 Nov 2019 12:27:39 -0500 Received: by mail-ot1-f66.google.com with SMTP id 94so13310727oty.8 for ; Mon, 25 Nov 2019 09:27:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ehtg0LDgFByK5WRliTFTt8kMCURVP50x4sdG0deprfY=; b=MsGNoi87guRmgvoKPI/D/lOK0M/mezTFZNaBeRkMe12Xdy9kJ4sQT0icrrtk/cQ7I+ XoOUItIX1FSBnkYcrZNSLWVdkvbyYY40szlADlj3lWhFlS5quaL3NVAC+VY+2TVDe7jI KJ+irc2cGqgmeHCwls2VTypiKNL4znvvZVBq7mEG+h2OaXeYPNK1I5f176snrGp3GBXx B8P0Z1NJcl6VH8gT+6fWXSAYEvX+5xYGf7Dpzb4m5qVgjkm4VYf1mvMik/y5MBs39Mlc IptXJd/rvAlz7G/M0cIit1TcxUUhwgZJZwIepPVz//Hd5W1aQ7RNB1qVciD6Jo0S4AlO 3PJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ehtg0LDgFByK5WRliTFTt8kMCURVP50x4sdG0deprfY=; b=cxioHVBX88xD3rY5gXuczF40HkPpNz57TXJQCMx++MCKI6PVDIRvGg97DfojprJpHl 2yr7bmx7+xTSgQLC+uVbazv00n/VR3M5O4KiUQXy50CzELw6m6/vIEaWeUTelYMfbreB WI2d8+44Thl26caUT296RyEnSxZJA6DiKXOBe8F+QJK3ZsrKS7+7yCNz3zWcpru5lClE bRgzMi3CyVfOfsK+0OcQirE2vksIB+PiglTCA8IF+Ti5x5CikZo3vfyTYTEhiVljfpjl p11Rp39H9QVApghNEvg91lvoA7rrX3cSBne2t0TK4jPABmvGGKmef2vdkgQQOGIWxO/D LZVA== X-Gm-Message-State: APjAAAW2yEsO1c9gSIOMZ/7XMP6ba4PYase2NKcuUVjx0M3o7ASGakWF 1iLtgUoGKpOBYlCpxvIy27q6rvVJnPbrVL7hHLMHYA== X-Received: by 2002:a9d:3982:: with SMTP id y2mr21401811otb.191.1574702857225; Mon, 25 Nov 2019 09:27:37 -0800 (PST) MIME-Version: 1.0 References: <1574166203-151975-1-git-send-email-alex.shi@linux.alibaba.com> <1574166203-151975-4-git-send-email-alex.shi@linux.alibaba.com> <20191119160456.GD382712@cmpxchg.org> <20191121220613.GB487872@cmpxchg.org> <20191122161652.GA489821@cmpxchg.org> In-Reply-To: From: Shakeel Butt Date: Mon, 25 Nov 2019 09:27:25 -0800 Message-ID: Subject: Re: [PATCH v4 3/9] mm/lru: replace pgdat lru_lock with lruvec lock To: Alex Shi Cc: Johannes Weiner , Cgroups , LKML , Linux MM , Andrew Morton , Mel Gorman , Tejun Heo , Hugh Dickins , Konstantin Khlebnikov , Daniel Jordan , Yang Shi , Matthew Wilcox , Michal Hocko , Vladimir Davydov , Roman Gushchin , Chris Down , Thomas Gleixner , Vlastimil Babka , Qian Cai , Andrey Ryabinin , "Kirill A. Shutemov" , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , David Rientjes , "Aneesh Kumar K.V" , swkhack , "Potyra, Stefan" , Mike Rapoport , Stephen Rothwell , Colin Ian King , Jason Gunthorpe , Mauro Carvalho Chehab , Peng Fan , Nikolay Borisov , Ira Weiny , Kirill Tkhai , Yafang Shao Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 25, 2019 at 1:26 AM Alex Shi wrote: > > > > > > But that leaves me with one more worry: compaction. We locked out > > charge moving now, so between that and knowing that the page is alive, > > we have page->mem_cgroup stable. But compaction doesn't know whether > > the page is alive - it comes from a pfn and finds out using PageLRU. > > > > In the current code, pgdat->lru_lock remains the same before and after > > the page is charged to a cgroup, so once compaction has that locked > > and it observes PageLRU, it can go ahead and isolate the page. > > > > But lruvec->lru_lock changes during charging, and then compaction may > > hold the wrong lock during isolation: > > > > compaction: generic_file_buffered_read: > > > > page_cache_alloc() > > > > !PageBuddy() > > > > lock_page_lruvec(page) > > lruvec = mem_cgroup_page_lruvec() > > spin_lock(&lruvec->lru_lock) > > if lruvec != mem_cgroup_page_lruvec() > > goto again > > > > add_to_page_cache_lru() > > mem_cgroup_commit_charge() > > page->mem_cgroup = foo > > lru_cache_add() > > __pagevec_lru_add() > > SetPageLRU() > > > > if PageLRU(page): > > __isolate_lru_page() > > > > I don't see what prevents the lruvec from changing under compaction, > > neither in your patches nor in Hugh's. Maybe I'm missing something? > > > > Hi Johannes, > > It looks my patch do the lruvec recheck/relock after PageLRU in compaction.c. > It should be fine for your question. So I will try more testing after all changes. Actually no, unless PageLRU check and taking lruvec lock are atomic, the race mentioned by Johannes still exist. Shakeel