Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752337AbcCaBkf (ORCPT ); Wed, 30 Mar 2016 21:40:35 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:32348 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750704AbcCaBke (ORCPT ); Wed, 30 Mar 2016 21:40:34 -0400 Subject: Re: [PATCH] Revert "mm/page_alloc: protect pcp->batch accesses with ACCESS_ONCE" To: Hekuang , Michal Hocko References: <1459333327-89720-1-git-send-email-hekuang@huawei.com> <20160330103839.GA4773@techsingularity.net> <56FBAFA0.3010604@huawei.com> <20160330111044.GA4324@dhcp22.suse.cz> <56FC7A02.1080201@huawei.com> CC: Mel Gorman , , , , , , , , , , , From: Zefan Li Message-ID: <56FC7FD2.9000203@huawei.com> Date: Thu, 31 Mar 2016 09:39:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56FC7A02.1080201@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.19.236] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.56FC7FE6.0046,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 154adee4f8314d664d302d1bac020a36 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1526 Lines: 34 On 2016/3/31 9:14, Hekuang wrote: > Hi > > 在 2016/3/30 19:10, Michal Hocko 写道: >> On Wed 30-03-16 18:51:12, Hekuang wrote: >>> hi >>> >>> 在 2016/3/30 18:38, Mel Gorman 写道: >>>> On Wed, Mar 30, 2016 at 10:22:07AM +0000, He Kuang wrote: >>>>> This reverts commit 998d39cb236fe464af86a3492a24d2f67ee1efc2. >>>>> >>>>> When local irq is disabled, a percpu variable does not change, so we can >>>>> remove the access macros and let the compiler optimize the code safely. >>>>> >>>> batch can be changed from other contexts. Why is this safe? >>>> >>> I've mistakenly thought that per_cpu variable can only be accessed by that >>> cpu. >> git blame would point you to 998d39cb236f ("mm/page_alloc: protect >> pcp->batch accesses with ACCESS_ONCE"). I haven't looked into the code >> deeply to confirm this is still the case but it would be a good lead >> that this is not that simple. ACCESS_ONCE resp. {READ,WRITE}_ONCE are >> usually quite subtle so I would encourage you or anybody else who try to >> remove them to study the code and the history deeper before removing >> them. >> > Thank you for responding, I've read that commit and related articles and not sending > mail casually, though you may think it's a stupid patch. I'm a beginner and I think > sending mails to maillist is a effective way to learn kernel, And, sure i'll be more careful and > well prepared next time :) > pcp->batch can be changed in a different cpu. You may read percpu_pagelist_fraction_sysctl_handler() to see how that can happen.