From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753238AbcEMOXH (ORCPT ); Fri, 13 May 2016 10:23:07 -0400 Received: from www.linutronix.de ([62.245.132.108]:58242 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751899AbcEMOXG (ORCPT ); Fri, 13 May 2016 10:23:06 -0400 Date: Fri, 13 May 2016 16:21:19 +0200 (CEST) From: Thomas Gleixner To: Vikram Mulukutla cc: peterz@infradead.org, linux-kernel@vger.kernel.org Subject: Re: Additional compiler barrier required in sched_preempt_enable_no_resched? In-Reply-To: <573576B3.50908@codeaurora.org> Message-ID: References: <573576B3.50908@codeaurora.org> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 May 2016, Vikram Mulukutla wrote: > preempt_disable(); > /* --cut, lots of code-- */ > preempt_enable_no_resched(); > put_user() > preempt_disable(); > > (If you wish to seriously question the usage of the preempt API in this > manner, I unfortunately have no comment since I didn't write the code.) > > This particular block of code was causing lockups and crashes on a certain > ARM64 device. The generated assembly revealed that the compiler was simply > optimizing out the increment and decrement of the preempt count, allowing > put_user to run without preemption enabled, causing all sorts of badness. > Since put_user doesn't actually access the preempt count and translates to > just a few instructions without any branching, I suppose that the compiler > figured it was OK to optimize. > > The immediate solution is to add a compiler barrier to the code above, but > should sched_preempt_enable_no_resched have an additional compiler barrier preempt_enable_no_resched() should not be used at all. Use preempt_enable(). Thanks, tglx