Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp760587ybh; Sat, 18 Jul 2020 21:02:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRBS+gKTPdas84D0eXbnvL0wjmJo3NLzxoyqs3fdwGiuEWY/Jh8MQuqwJAKkJFrC8xwB7X X-Received: by 2002:a05:6402:1c8f:: with SMTP id cy15mr16121145edb.308.1595131338200; Sat, 18 Jul 2020 21:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595131338; cv=none; d=google.com; s=arc-20160816; b=ZVNuYXZD2gEHhpCzN3XNDuSHQVpzc6Nt8EkT3/9AY7xnC5NpyIXQUq8Y2Au7NqKGEG ZCJNJowFCGMcN6LNIPCVA1qF7bHkGGuu6ew0H9bE5UL8rQiis8KVQ5U5C550u9g2LJFF BNQlsL9r1h6rfrAlf4slzu5U/zbeSmzm1p2qZdpDNtgZRczjEsc5eBjDjeG4nU4GIvZH ckWHrnAMELvbzYDwbCu8u3H8Ga2H57iSvp8iQwMl1Jx5K9Va7Y9MFBBFG2iqcudlnp6V tSDuwXKUbFQ19x0yNN51lXOgKw+US60P/+qdn+68KpH17wz3RoZxvXM1p1FWZrTAVSQQ WlDA== 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=tOBY+ZylGKP3WssjbGfleEKWzuFVVgu0OXVQHSoohGI=; b=pBbD7KxZsBQQfeUXfnDqFhmIxGio1f/kF8rNjvIw2NnnjS5RmVzrK6XKfZvpOE34tS RoC86j9ytLTVMH1YnvQO3SOHJhKX/xnbJwcJiFpZxW32NNcPMwNa8rRIYeByzuxTN2Jw SV496GyQ1qXb5dTpb/CxfIcLBo7/kRVrmkHyonj9rLsU3/udky8QBqWnaYzO8pjQwqWZ sL0jLMsRL4oH1b2YCMn2CTxLgLTp+xN0M84A5pefSI7PLDDBdJmKbEgYpjCkKFTq6lsu eJuWGN447p/qXSxqNlCuxoWEjPPibbXlehNIHm2jIbk3cJMzUj5DJSR8BMVS+SfrLwXM fLyw== 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 l14si8126360edq.355.2020.07.18.21.01.54; Sat, 18 Jul 2020 21:02: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; 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 S1726412AbgGSD7n (ORCPT + 99 others); Sat, 18 Jul 2020 23:59:43 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:56930 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbgGSD7m (ORCPT ); Sat, 18 Jul 2020 23:59:42 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07484;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0U36eCsi_1595131176; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U36eCsi_1595131176) by smtp.aliyun-inc.com(127.0.0.1); Sun, 19 Jul 2020 11:59:37 +0800 Subject: Re: [PATCH v16 15/22] mm/compaction: do page isolation first in compaction 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" References: <1594429136-20002-1-git-send-email-alex.shi@linux.alibaba.com> <1594429136-20002-16-git-send-email-alex.shi@linux.alibaba.com> From: Alex Shi Message-ID: Date: Sun, 19 Jul 2020 11:59:36 +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/18 上午12:09, Alexander Duyck 写道: >>> I wonder if it wouldn't make sense to combine these two atomic ops >>> with tests and the put_page into a single inline function? Then it >>> could be possible to just do one check and if succeeds you do the >>> block of code below, otherwise you just fall-through into the -EBUSY >>> case. >>> >> Uh, since get_page changes page->_refcount, TestClearPageLRU changes page->flags, >> So I don't know how to combine them, could you make it more clear with code? > Actually it is pretty straight forward. Something like this: > static inline bool get_page_unless_zero_or_nonlru(struct page *page) > { > if (get_page_unless_zero(page)) { > if (TestClearPageLRU(page)) > return true; > put_page(page); > } > return false; > } > > You can then add comments as necessary. The general idea is you are > having to do this in two different spots anyway so why not combine the > logic? Although it does assume you can change the ordering of the > other test above. It doesn't look different with original code, does it? Thanks Alex