From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755723AbdKBRpF (ORCPT ); Thu, 2 Nov 2017 13:45:05 -0400 Received: from out0-205.mail.aliyun.com ([140.205.0.205]:44758 "EHLO out0-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752777AbdKBRpE (ORCPT ); Thu, 2 Nov 2017 13:45:04 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03275;MF=yang.s@alibaba-inc.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---.9IutLtW_1509644689; Subject: Re: [PATCH] mm: use in_atomic() in print_vma_addr() To: Michal Hocko , mingo@redhat.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1509572313-102989-1-git-send-email-yang.s@alibaba-inc.com> <20171102075744.whhxjmqbdkfaxghd@dhcp22.suse.cz> From: "Yang Shi" Message-ID: Date: Fri, 03 Nov 2017 01:44:44 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20171102075744.whhxjmqbdkfaxghd@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/2/17 12:57 AM, Michal Hocko wrote: > On Thu 02-11-17 05:38:33, Yang Shi wrote: >> commit 3e51f3c4004c9b01f66da03214a3e206f5ed627b >> ("sched/preempt: Remove PREEMPT_ACTIVE unmasking off in_atomic()") makes >> in_atomic() just check the preempt count, so it is not necessary to use >> preempt_count() in print_vma_addr() any more. Replace preempt_count() to >> in_atomic() which is a generic API for checking atomic context. > > But why? Is there some general work to get rid of the direct preempt_count > usage outside of the generic API? I may not articulate it in the commit log, I would say "in_atomic" is *preferred* API for checking atomic context instead of preempt_count() which should be used for retrieving the preemption count value. I would say there is not such general elimination work undergoing right now, but if we go through the kernel code, almost everywhere "in_atomic" is used for such use case already, except two places: - print_vma_addr() - debug_smp_processor_id() Both came from Ingo long time ago before commit 3e51f3c4004c9b01f66da03214a3e206f5ed627b ("sched/preempt: Remove PREEMPT_ACTIVE unmasking off in_atomic()"). But, after this commit was merged, I don't see why *not* use in_atomic() to follow the convention. Thanks, Yang > >> Signed-off-by: Yang Shi >> --- >> mm/memory.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/memory.c b/mm/memory.c >> index a728bed..19b684e 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -4460,7 +4460,7 @@ void print_vma_addr(char *prefix, unsigned long ip) >> * Do not print if we are in atomic >> * contexts (in exception stacks, etc.): >> */ >> - if (preempt_count()) >> + if (in_atomic()) >> return; >> >> down_read(&mm->mmap_sem); >> -- >> 1.8.3.1 >