Return-Path: linux-nfs-owner@vger.kernel.org Received: from mail-vc0-f169.google.com ([209.85.220.169]:40523 "EHLO mail-vc0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922Ab3EEAXC (ORCPT ); Sat, 4 May 2013 20:23:02 -0400 Received: by mail-vc0-f169.google.com with SMTP id gd11so2287355vcb.14 for ; Sat, 04 May 2013 17:23:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20130505000528.GA25454@amd.pavel.ucw.cz> References: <1367615050-3894-1-git-send-email-ccross@android.com> <1367615050-3894-2-git-send-email-ccross@android.com> <20130504130440.GC13770@amd.pavel.ucw.cz> <20130504225715.GB24276@amd.pavel.ucw.cz> <20130505000528.GA25454@amd.pavel.ucw.cz> Date: Sat, 4 May 2013 17:23:01 -0700 Message-ID: Subject: Re: [PATCH 2/2] lockdep: check that no locks held at freeze time From: Colin Cross To: Pavel Machek Cc: Andrew Morton , lkml , Trond Myklebust , Len Brown , "Rafael J. Wysocki" , Peter Zijlstra , Ingo Molnar , "J. Bruce Fields" , "David S. Miller" , Andrew Morton , Mandeep Singh Baines , Paul Walmsley , Al Viro , "Eric W. Biederman" , Oleg Nesterov , linux-nfs@vger.kernel.org, Linux PM list , netdev , Linus Torvalds , Tejun Heo , Ben Chan Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-nfs-owner@vger.kernel.org List-ID: On Sat, May 4, 2013 at 5:05 PM, Pavel Machek wrote: > Hi! > >> >> >> --- a/kernel/exit.c >> >> >> +++ b/kernel/exit.c >> >> >> @@ -835,7 +835,7 @@ void do_exit(long code) >> >> >> /* >> >> >> * Make sure we are holding no locks: >> >> >> */ >> >> >> - debug_check_no_locks_held(tsk); >> >> >> + debug_check_no_locks_held(); >> >> > >> >> > Is task guaranteed == current? >> >> >> >> Yes, the first line of do_exit is: >> >> struct task_struct *tsk = current; >> > >> > Aha, I understand it now. >> > >> > Accessing current is slower than local variable. So your "new" code >> > will work but will be slower. Please revert this part. >> >> Using current instead of passing in tsk was done at Andrew Morton's >> suggestion, and makes no difference from the freezer's perspective >> since it would have to use current to get the task to pass in, so I'm >> going to leave it as is. > > Well, current is: > > static inline struct thread_info *current_thread_info(void) > { > register unsigned long sp asm ("sp"); > return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); > } > > #define get_current() (current_thread_info()->task) > > #define current get_current() > > Instead of passing computed value to debug_check_no_locks_held(), you > force it to be computed again. do_exit() performance matters for > configure scripts, etc. > > I'd say it makes sense to keep the optimalization. akpm can correct > me. That translates to 3 instructions, with no memory accesses: c0008350: e1a0300d mov r3, sp c0008354: e3c32d7f bic r2, r3, #8128 ; 0x1fc0 c0008358: e3c2203f bic r2, r2, #63 ; 0x3f