Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1115434ybj; Tue, 5 May 2020 13:23:09 -0700 (PDT) X-Google-Smtp-Source: APiQypKq8iMSqY6fun9ZKnf2D7RAiLRHfbRV5EYamPpHKL+ts2EOyOm9J2xwtRomxRX5ENw2uAlu X-Received: by 2002:a05:6402:1adc:: with SMTP id ba28mr4360995edb.336.1588710189615; Tue, 05 May 2020 13:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588710189; cv=none; d=google.com; s=arc-20160816; b=BEt9RwlTdq9TesDZn1btM4BZfX2Y09nERSVy0bozgtZiAHEfCWxQcIeibuazEwOCOF hBmoava2pvfg8FLg4mfYz+h7gz4U3pCDuCzfk8YZN+ku4xf6bv+mjCrhjk+rRqpwf98O aMxgVKFd7JVZxUqGaWj0+MsZU4kxwdg8OqTTl0NEOxUai6VJ5V3oYboYpnyLrTfcQJL/ xMmQdTqi7orWSDQcmWaDqYdZdUiWtOLAav7XU0E37yGNymLuW1DvagpotiHg8fdybxE/ 2Qhyt/2O6KjJfnHQG8oRL8A1jQmxnL6XbSbgep6lB7MkEjFsf8Cn7XJkXq5nR1l9gsjn Gnuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=d+8PTjATP8NZqO9fGYiFQPas1X6ycV89Bl+038dCB0U=; b=EF8rNMHV5YSnv9cPNsyPwOXAUQibiMa3LzrJjFAgHRxPeV48e8EDHRpPgreYQH/CNJ VxmMqOoe+0PymrcHXbRJBYk/Bep76ASvCuz+8vT3vIyUM1UVNEaL29WxtLQ2J8TikqOv CqJXwN6rabrMR8R6Sp+MQmy3EusX/jzt9DBrP+TPSujvKXODgVwXCnJGc7wTvrP+RxBU J0E2dkZj7KSj+pnFIQ6s+gkb87iLd6wRgrQJW/BR8uZrvM32HkNgH1sGzc2m3UN9IcWU VpXfXLeR1WtaF2eMbwS1pk9rSZIrIEoGzdhhl7gwEz/pRAfyYNEmUqyE1xHuMrtdg+lq 4IQQ== 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 g23si1851904ejh.337.2020.05.05.13.22.46; Tue, 05 May 2020 13:23:09 -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 S1728569AbgEEUTK (ORCPT + 99 others); Tue, 5 May 2020 16:19:10 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:56431 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727785AbgEEUTK (ORCPT ); Tue, 5 May 2020 16:19:10 -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=e01e01419;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0Txb6obD_1588709945; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0Txb6obD_1588709945) by smtp.aliyun-inc.com(127.0.0.1); Wed, 06 May 2020 04:19:07 +0800 Subject: Re: [RFC][PATCH 1/2] mm/migrate: remove extra page_count() check To: Dave Hansen , linux-kernel@vger.kernel.org Cc: npiggin@gmail.com, akpm@linux-foundation.org, willy@infradead.org, linux-mm@kvack.org References: <20200501210516.DFAFF456@viggo.jf.intel.com> <20200501210518.DA161B7E@viggo.jf.intel.com> From: Yang Shi Message-ID: <2aa6a7b8-fc9b-e903-a665-c4cd516392b8@linux.alibaba.com> Date: Tue, 5 May 2020 13:18:55 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20200501210518.DA161B7E@viggo.jf.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/1/20 2:05 PM, Dave Hansen wrote: > From: Dave Hansen > > This is not a bug fix. It was found by inspection, but I believe > that it is confusing as it stands. > > First, page_ref_freeze() is implemented internally with: > > atomic_cmpxchg(&page->_refcount, expected, 0) == expected > > The "cmp" part of cmpxchg is making sure that _refcount==expected > which means that there's an implicit check here, equivalent to: > > page_count(page) == expected_count > > This appears to have originated in "e286781: mm: speculative page > references", which is pretty ancient. This check is also somewhat > dangerous to have here because it might lead someone to think that > page_ref_freeze() *doesn't* do its own page_count() checking. > > Remove the unnecessary check. Make sense to me. Acked-by: Yang Shi > > Signed-off-by: Dave Hansen > Cc: Nicholas Piggin > Cc: Andrew Morton > Cc: Matthew Wilcox (Oracle) > Cc: Yang Shi > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > --- > > b/mm/migrate.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff -puN mm/migrate.c~remove_extra_page_count_check mm/migrate.c > --- a/mm/migrate.c~remove_extra_page_count_check 2020-05-01 14:00:42.331525924 -0700 > +++ b/mm/migrate.c 2020-05-01 14:00:42.336525924 -0700 > @@ -425,11 +425,12 @@ int migrate_page_move_mapping(struct add > newzone = page_zone(newpage); > > xas_lock_irq(&xas); > - if (page_count(page) != expected_count || xas_load(&xas) != page) { > + if (xas_load(&xas) != page) { > xas_unlock_irq(&xas); > return -EAGAIN; > } > > + /* Freezing will fail if page_count()!=expected_count */ > if (!page_ref_freeze(page, expected_count)) { > xas_unlock_irq(&xas); > return -EAGAIN; > _