Received: by 10.213.65.68 with SMTP id h4csp575850imn; Fri, 23 Mar 2018 10:43:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELvzRGpTDvzu0KDheWbjOLw4sCmitxUcXUCNSt4w5ds556UtUUiJxqXCBLC4D/q2tJpcBRra X-Received: by 2002:a17:902:d891:: with SMTP id b17-v6mr1212778plz.55.1521827015280; Fri, 23 Mar 2018 10:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521827015; cv=none; d=google.com; s=arc-20160816; b=p6NnF60PiPquvK3dOaniOkFaLJgnqaKWm8OB2u/CWuvQC13WpEqnXGyEvM5o06fT09 yrIvphpMEADavPWGBrU/AcqmUK3x8favUUjLLn3dsa3RazmKyZggbT0VeCnIT0rX7cLh cmQkHtnc9P/sfPGFY/JvC0Y2eKfDe3OaCAh1v03D5lZblnDqLXbw0PSD1h6rs6V9R28l TcvOhNmR1gQdw8gxgl5k9GA5rNUx6uWimpk1tpKN0Ibst7EoEOHcyL8h1jUYF28bUY+R NmnV5ngbWlOspjEnQYZFCT1V9JhbuGlOaUReF9I8AM4j0YXpRpVYeeqLsenIvkvQXXd/ Z6Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=6hYIKW6WWmqahijD9UFct1h4KvSit59k8xfVfbUY7tk=; b=iUBTkjk2yC0JwOG0MBW3mnKLTEnb1xC89PnDU8kbHRk/Mgg07wJ9oJla2/la5zK2r8 JxnyfbMZajKYjKkMfctzz4BY5x+7p4RWapiF8y/lfoxmc0I89R0X6u5C8of1Cn2e/32s RR0uOQfhcs+VZB7BCN/elzDMgsz5f3f2BaHUu/Z0z45akKJoHQgDNjH4/FJlo6WEFfBB TbtFZlYfhXXBvcNhYenCCdkzXs9cWqok4rKZmlIVbHqf05fnEynnzqSWTIgZ+bIzdjrh f2OC/F6bMGh6CWP2SsylzPLZtp30fUTRr+U9HPQtKiD3ZInvUM9hx7iXJvgvSG344LD+ ydhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w64si6357918pgd.176.2018.03.23.10.43.20; Fri, 23 Mar 2018 10:43:35 -0700 (PDT) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752050AbeCWRmR (ORCPT + 99 others); Fri, 23 Mar 2018 13:42:17 -0400 Received: from mx0a-00010702.pphosted.com ([148.163.156.75]:57318 "EHLO mx0b-00010702.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751595AbeCWRmN (ORCPT ); Fri, 23 Mar 2018 13:42:13 -0400 Received: from pps.filterd (m0098781.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2NHeeUK006235; Fri, 23 Mar 2018 12:42:03 -0500 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2gurjmqjmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Mar 2018 12:42:03 -0500 Received: from us-aus-exch1.ni.corp.natinst.com (us-aus-exch1.ni.corp.natinst.com [130.164.68.11]) by us-aus-skprod2.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id w2NHg2vH020231 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 23 Mar 2018 12:42:02 -0500 Received: from us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) by us-aus-exch1.ni.corp.natinst.com (130.164.68.11) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Fri, 23 Mar 2018 12:42:02 -0500 Received: from jcartwri.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Fri, 23 Mar 2018 12:42:02 -0500 Received: by jcartwri.amer.corp.natinst.com (Postfix, from userid 1000) id 84354301944; Fri, 23 Mar 2018 12:42:02 -0500 (CDT) Date: Fri, 23 Mar 2018 12:42:02 -0500 From: Julia Cartwright To: Joe Korty CC: , , , , , Subject: Re: [PATCH RT] Defer migrate_enable migration while task state != TASK_RUNNING Message-ID: <20180323174202.GH10942@jcartwri.amer.corp.natinst.com> References: <20180323150959.GA16131@zipoli.concurrent-rt.com> <20180323165921.GG10942@jcartwri.amer.corp.natinst.com> <20180323172131.GA2670@zipoli.concurrent-rt.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180323172131.GA2670@zipoli.concurrent-rt.com> User-Agent: Mutt/1.9.3 (2018-01-21) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-23_11:,, signatures=0 X-Proofpoint-Spam-Reason: safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 23, 2018 at 01:21:31PM -0400, joe.korty@concurrent-rt.com wrote: > On Fri, Mar 23, 2018 at 11:59:21AM -0500, Julia Cartwright wrote: > > On Fri, Mar 23, 2018 at 11:09:59AM -0400, joe.korty@concurrent-rt.com wrote: > > > I see the below kernel splat in 4.9-rt when I run a test program that > > > continually changes the affinity of some set of running pids: > > > > > > do not call blocking ops when !TASK_RUNNING; state=2 set at ... > > > ... > > > stop_one_cpu+0x60/0x80 > > > migrate_enable+0x21f/0x3e0 > > > rt_spin_unlock+0x2f/0x40 > > > prepare_to_wait+0x5c/0x80 > > > ... > > > > This is clearly a problem. > > > > > The reason is that spin_unlock, write_unlock, and read_unlock call > > > migrate_enable, and since 4.4-rt, migrate_enable will sleep if it discovers > > > that a migration is in order. But sleeping in the unlock services is not > > > expected by most kernel developers, > > > > I don't buy this, see below: > > > > > and where that counts most is in code sequences like the following: > > > > > > set_current_state(TASK_UNINTERRUPIBLE); > > > spin_unlock(&s); > > > schedule(); > > > > The analog in mainline is CONFIG_PREEMPT and the implicit > > preempt_enable() in spin_unlock(). In this configuration, a kernel > > developer should _absolutely_ expect their task to be suspended (and > > potentially migrated), _regardless of the task state_ if there is a > > preemption event on the CPU on which this task is executing. > > > > Similarly, on RT, there is nothing _conceptually_ wrong on RT with > > migrating on migrate_enable(), regardless of task state, if there is a > > pending migration event. > > My understanding is, in standard Linux and in rt, setting > task state to anything other than TASK_RUNNING in of itself > blocks preemption. I'm assuming you're referring to the window of time between a task setting its state to !TASK_RUNNING and schedule()? The task remains preemptible in this window. > A preemption is not really needed here as it is expected that there is > a schedule() written in that will shortly be executed. > > And if a 'involuntary schedule' (ie, preemption) were allowed to occur > between the task state set and the schedule(), that would change the > task state back to TASK_RUNNING; This isn't the case. A preempted task preserves its state. Julia