Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751510AbcLEIZS (ORCPT ); Mon, 5 Dec 2016 03:25:18 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:29319 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbcLEIZR (ORCPT ); Mon, 5 Dec 2016 03:25:17 -0500 Message-ID: <584523E4.9030600@huawei.com> Date: Mon, 5 Dec 2016 16:23:00 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Andrew Morton , Mel Gorman , Yaowei Bai CC: Linux MM , LKML , Yisheng Xie Subject: [RFC PATCH] mm: use ACCESS_ONCE in page_cpupid_xchg_last() Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 724 Lines: 25 By reading the code, I find the following code maybe optimized by compiler, maybe page->flags and old_flags use the same register, so use ACCESS_ONCE in page_cpupid_xchg_last() to fix the problem. Signed-off-by: Xishi Qiu --- mm/mmzone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mmzone.c b/mm/mmzone.c index 5652be8..e0b698e 100644 --- a/mm/mmzone.c +++ b/mm/mmzone.c @@ -102,7 +102,7 @@ int page_cpupid_xchg_last(struct page *page, int cpupid) int last_cpupid; do { - old_flags = flags = page->flags; + old_flags = flags = ACCESS_ONCE(page->flags); last_cpupid = page_cpupid_last(page); flags &= ~(LAST_CPUPID_MASK << LAST_CPUPID_PGSHIFT); -- 1.8.3.1