Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4374049pxa; Mon, 10 Aug 2020 07:42:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0w+CCG0iHAh96mkNuRXLzKGC/4azu6Yc459PByfGDn9n8yH4DOJ3/ioucVFV//oi6CXmL X-Received: by 2002:a17:906:7698:: with SMTP id o24mr22740510ejm.182.1597070538121; Mon, 10 Aug 2020 07:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597070538; cv=none; d=google.com; s=arc-20160816; b=YgO2qCa9pKZ3tyXFzVPLpcRV+/hT1LeDE36Qw6jnb/+yXMr8sgzPfTAeZSMiXcX29E YWkN32IC8gwQNrLZ/NcrF9zYLuLBn60rPQAPNk8S+P8tK6/vipDEzscrADV9OqWAo0CI gEstGyWCsXgpCNREphGJcCQg8fplDekeYHufI74k1uRkpcUAwbSaDqrvaP0sTZ4eG7RM i3JS5OTmNNgiqIYKLp2HAHheiOxIFpkQaVB9QVYwX7thYeODf6SEpzW8QQEX/T38b2rY 078XInRp8EPmZS4cXmaxRSImMFBG4ROYMH7fbQTUOhzf5V4cZQjeVAyhgzcskE2VzH7f m3BA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=AidFlRL4Ug1HXYYI29mKf2liuKC4nCVYEFXiYCfw8vA=; b=TcoAEw/s3vuS/mAK/kctKn9Xe6jlIo4SdqVd1hHSklxvvQSAoeWirugTju14khtrWa aD+upGtByxFjPNzfBI2X2tUQ4rBkTPQOXV1W08TeediJV2N6ZDwnnW4oXinxguHj2vUf omabABHaWLmfkzrEtYkr/C6dHPex8R9yXPsWFauS4wHcTtnEWUDeOdp3VCdhTYZ1COoE N5PxCQQSkOt81ubdtZxWHnJrHnho0mRzaebmvn12J4mJKYa5uhnev7ig8kMZao0NdZfR OK/4E9EOx6lnOE8QjkysxNnGv4+tauO0ENrFoz6c0SUh2+Yz+lgIQrUfs6K6jrDNda0q WHCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CnzTfUG1; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si10429051edr.403.2020.08.10.07.41.55; Mon, 10 Aug 2020 07:42:18 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CnzTfUG1; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbgHJOlX (ORCPT + 99 others); Mon, 10 Aug 2020 10:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbgHJOlW (ORCPT ); Mon, 10 Aug 2020 10:41:22 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8658DC061756; Mon, 10 Aug 2020 07:41:22 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id z17so7726926ill.6; Mon, 10 Aug 2020 07:41:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=AidFlRL4Ug1HXYYI29mKf2liuKC4nCVYEFXiYCfw8vA=; b=CnzTfUG1SpGkNdLlwHUtFMtEAs/lYxwUd5HQM1e687MC6Hx2DVg0XbIOvx3VGO/z74 /BRzNFMM9NnDz2jGQ2eASuxPpT/aB1AR3sUY0B97X9ZHGQols8ol6MIVMfMib/g48r13 +dOLOiywM+Fr6cEXRyNvtKTpvkt+vkdJGpS12tNiDQHg2E6/oVBCkQt5kLDzQO++FKwV Zwa8lmALUMlCqBfNzCEQDtTttA1A9PzbVF4AwYgmbywQm+6czKeFZ5vEr8+0JbKwwxts sbFCWoV2tT9H22iM4NLHNgkJvREVNYHhnlEWB8Dlv9Z67SOBGa1vmez+KhDjL99Dr6uA yZxA== 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:content-transfer-encoding; bh=AidFlRL4Ug1HXYYI29mKf2liuKC4nCVYEFXiYCfw8vA=; b=joOGrU3AHTTXbE887V1t4zygaZxJCDUMf4JRiY/8hlHNaSwcSWmbvKTA+2r4pOgUwA kALmXK7OUx0Ovjj/q9EjcuIltsZKrBCye4JTgs+H9VvDcAF6H9O/Z1a4jwgfIYSGapYg TMPoaZjI/x2kWDJCLqeXpp7Saf32n86hd3TdC7q5/cC3oVhBr8+uSMkQqFza25pIkMwK To0CS7ZCRbZa+0DTiM23MZZ6pz6E3fyNJ0EXd/YWcNrul3w967Y4h675PSaFKGpnb+dL cK9wQhzWSuitRJHdcjzwiR33r7fcLPzbG6HCEVL9hrAEZi2IMdBzVBhXX8mChIgX5C3J KqYA== X-Gm-Message-State: AOAM533ZAd+EgrGc/5tKgWs3eI371X/d+IMmto1a3bRRBtF6hXBZYJKa 74MhQr7uEFB9IUmxKVEnZzpQnIsKe6rQzGwijJQ= X-Received: by 2002:a05:6e02:143:: with SMTP id j3mr16319712ilr.97.1597070481282; Mon, 10 Aug 2020 07:41:21 -0700 (PDT) MIME-Version: 1.0 References: <1595681998-19193-1-git-send-email-alex.shi@linux.alibaba.com> <1595681998-19193-15-git-send-email-alex.shi@linux.alibaba.com> <241ca157-104f-4f0d-7d5b-de394443788d@linux.alibaba.com> <8dbd004e-8eba-f1ec-a5eb-5dc551978936@linux.alibaba.com> In-Reply-To: <8dbd004e-8eba-f1ec-a5eb-5dc551978936@linux.alibaba.com> From: Alexander Duyck Date: Mon, 10 Aug 2020 07:41:10 -0700 Message-ID: Subject: Re: [PATCH v17 14/21] mm/compaction: do page isolation first in compaction To: Alex Shi 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 10, 2020 at 6:10 AM Alex Shi wrote= : > > > > =E5=9C=A8 2020/8/7 =E4=B8=8B=E5=8D=8810:51, Alexander Duyck =E5=86=99=E9= =81=93: > > I wonder if this entire section shouldn't be restructured. This is the > > only spot I can see where we are resetting the LRU flag instead of > > pulling the page from the LRU list with the lock held. Looking over > > the code it seems like something like that should be possible. I am > > not sure the LRU lock is really protecting us in either the > > PageCompound check nor the skip bits. It seems like holding a > > reference on the page should prevent it from switching between > > compound or not, and the skip bits are per pageblock with the LRU bits > > being per node/memcg which I would think implies that we could have > > multiple LRU locks that could apply to a single skip bit. > > Hi Alexander, > > I don't find problem yet on compound or skip bit usage. Would you clarify= the > issue do you concerned? > > Thanks! The point I was getting at is that the LRU lock is being used to protect these and with your changes I don't think that makes sense anymore. The skip bits are per-pageblock bits. With your change the LRU lock is now per memcg first and then per node. As such I do not believe it really provides any sort of exclusive access to the skip bits. I still have to look into this more, but it seems like you need a lock per either section or zone that can be used to protect those bits and deal with this sooner rather than waiting until you have found an LRU page. The one part that is confusing though is that the definition of the skip bits seems to call out that they are a hint since they are not protected by a lock, but that is exactly what has been happening here. The point I was getting at with the PageCompound check is that instead of needing the LRU lock you should be able to look at PageCompound as soon as you call get_page_unless_zero() and preempt the need to set the LRU bit again. Instead of trying to rely on the LRU lock to guarantee that the page hasn't been merged you could just rely on the fact that you are holding a reference to it so it isn't going to switch between being compound or order 0 since it cannot be freed. It spoils the idea I originally had of combining the logic for get_page_unless_zero and TestClearPageLRU into a single function, but the advantage is you aren't clearing the LRU flag unless you are actually going to pull the page from the LRU list. My main worry is that this is the one spot where we appear to be clearing the LRU bit without ever actually pulling the page off of the LRU list, and I am thinking we would be better served by addressing the skip and PageCompound checks earlier rather than adding code to set the bit again if either of those cases are encountered. This way we don't pseudo-pin pages in the LRU if they are compound or supposed to be skipped. Thanks. - Alex