From patchwork Fri Feb 14 12:35:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 24649 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 16A2D202E2 for ; Fri, 14 Feb 2014 12:35:56 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id g12sf49232879oah.10 for ; Fri, 14 Feb 2014 04:35:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:in-reply-to:user-agent:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-disposition; bh=zhR7bUU2haxojd1uXTiojq8cd5u9iw7ReZbRlCcJB4o=; b=LkPZgvy1MKg76ou56/ei46+3X0VTx88NwFPKyzjd9JfS3LQXALkA+2A/eYRn620z/I e33lubUgdtQJ1E7Yh0hj+K5cNtzG+SxajWOefM4MSrt55A8x86qRylipyTG8qe5uGzDW j1aB8SChDCNgDFb11VFTT6Yi+PONEaW4RK0CUMNGfUrAMH7mLm3kr5I5U8UI1+Gvt0ue iXcv65STPHE+jpwR4TQZevkS48ZvnHUgoipQ13shtQWPE7D/1hLRCFDy8tnHA8FvEH+m HGrKg4tiRWJptmZBB+PCeH4+EdaaN59uCU4xo/7kn3Nf8v2F2tOhG79MIgW2dzxVdV3k 5ucg== X-Gm-Message-State: ALoCoQntjZOIYL1bE3aX3Z9elscm9K0OFFv9xvPTp8Zmj2uz8KqE22IReBXtJBr0sIIHRCx8+iou X-Received: by 10.42.196.71 with SMTP id ef7mr2742284icb.24.1392381355936; Fri, 14 Feb 2014 04:35:55 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.100 with SMTP id 91ls53356qgi.18.gmail; Fri, 14 Feb 2014 04:35:55 -0800 (PST) X-Received: by 10.220.145.5 with SMTP id b5mr5336886vcv.9.1392381355833; Fri, 14 Feb 2014 04:35:55 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id qt5si1854941vcb.98.2014.02.14.04.35.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 04:35:55 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jx11so2408390veb.7 for ; Fri, 14 Feb 2014 04:35:55 -0800 (PST) X-Received: by 10.53.1.166 with SMTP id bh6mr73143vdd.64.1392381355446; Fri, 14 Feb 2014 04:35:55 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp105329vcz; Fri, 14 Feb 2014 04:35:54 -0800 (PST) X-Received: by 10.68.201.67 with SMTP id jy3mr8802403pbc.20.1392381354467; Fri, 14 Feb 2014 04:35:54 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix4si5653956pbb.269.2014.02.14.04.35.50; Fri, 14 Feb 2014 04:35:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752503AbaBNMfn (ORCPT + 27 others); Fri, 14 Feb 2014 07:35:43 -0500 Received: from fw-tnat.austin.arm.com ([217.140.110.23]:24048 "EHLO collaborate-mta1.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751788AbaBNMfm (ORCPT ); Fri, 14 Feb 2014 07:35:42 -0500 Received: from arm.com (e102109-lin.cambridge.arm.com [10.1.203.182]) by collaborate-mta1.arm.com (Postfix) with ESMTPS id 6B6FB13F6EE; Fri, 14 Feb 2014 06:35:41 -0600 (CST) Date: Fri, 14 Feb 2014 12:35:36 +0000 From: Catalin Marinas To: Kirill Tkhai Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , tkhai@yandex.ru Subject: Re: [PATCH] sched/core: Create new task with twice disabled preemption Message-ID: <20140214123536.GA12304@arm.com> References: <1392306716.5384.3.camel@tkhai> MIME-Version: 1.0 In-Reply-To: <1392306716.5384.3.camel@tkhai> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: catalin.marinas@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-Disposition: inline On Thu, Feb 13, 2014 at 07:51:56PM +0400, Kirill Tkhai wrote: > Preemption state on enter in finish_task_switch() is different > in cases of context_switch() and schedule_tail(). > > In the first case we have it twice disabled: at the start of > schedule() and during spin locking. In the second it is only > once: the value which was set in init_task_preempt_count(). > > For archs without __ARCH_WANT_UNLOCKED_CTXSW set this means > that all newly created tasks execute finish_arch_post_lock_switch() > and post_schedule() with preemption enabled. > > It seems there is possible a problem in rare situations on arm64, > when one freshly created thread preempts another before > finish_arch_post_lock_switch() has finished. If mm is the same, > then TIF_SWITCH_MM on the second won't be set. > > The second rare but possible issue is zeroing of post_schedule() > on a wrong cpu. > > So, lets fix this and unify preempt_count state. An alternative to your patch: diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b46131ef6aab..b932b6a4c716 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2210,6 +2210,10 @@ asmlinkage void schedule_tail(struct task_struct *prev) { struct rq *rq = this_rq(); +#ifndef __ARCH_WANT_UNLOCKED_CTXSW + /* In this case, finish_task_switch reenables preemption */ + preempt_disable(); +#endif finish_task_switch(rq, prev); /* @@ -2218,10 +2222,7 @@ asmlinkage void schedule_tail(struct task_struct *prev) */ post_schedule(rq); -#ifdef __ARCH_WANT_UNLOCKED_CTXSW - /* In this case, finish_task_switch does not reenable preemption */ preempt_enable(); -#endif if (current->set_child_tid) put_user(task_pid_vnr(current), current->set_child_tid); }