Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1055097imm; Wed, 4 Jul 2018 10:37:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe0G9aW/VO+QJRDRE7yymsdIX0mshUx+2/PNprl3G9Wm2brzkpNRZjZt9uQWCYxcLhwpsq2 X-Received: by 2002:a17:902:654b:: with SMTP id d11-v6mr2973461pln.8.1530725858319; Wed, 04 Jul 2018 10:37:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530725858; cv=none; d=google.com; s=arc-20160816; b=oNKvoR81iQNvhDu1OtcIW7iONzA7kb44F29m6Zntf7X8FTWf/yaUDUtlkOERveJt/R YmljACcVguRk88EuG4h8QZiH9QnyQlK7gamxFScmcI7RisOuwvOrAIV+beOxVUePA3le Sbs8AJM0tXeDi3xjHurJQKux6hgOrOvkycIhqes2UvC3ZDBV6QyPZzF7gOgr4IFJVRJx 3x7kdQLS61+AX+9zQ4zbkJU6aSX7mVfCWMFGRHHzvRWqmxNiPHGpztyqhwPIoUbBnAu2 WiyEFDr+EOXB/6Z6pDyMoWIYMbeot1duf1SvhXbsk+AfWfI9gGYRJ0Qk5x0gHZpc2V2I z9RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:content-disposition:mime-version :reply-to:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=oWbbXUOGQcvWHLjLkqhuB5dgwIyboeokdxdRofgI5D0=; b=mMaMh67otNZH8gtU/HGrjLb3zha7zpx+woDTOBycmWYnhPXY9lRFFanVnAzASEkBP1 qWq7Lhl2HUVZrrKUAMSg6MSiPNb8Pv0i/+Gev6C2hqtsSeggSf0Ay34mxtB5X95CzFU+ swlg/CnBRiSBGoht7U+ZVotBDzgPfUm+r/bE2i8RcV0EfhL8Qev5tPLFBbcl0D6UYYhh L/rB5Tx3FmgQguy55Z0md+yoc4smXZxQQub83MXfyBlxCXu2MINEs+Bsjkhl7ZHYrIKy 013FyGBfGaUDqiXzPy7GCuirOthkKKwBRdq5oBSA2oDogu1WewKypJVsCsSjJuDXeYwI HV2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@concurrentrt.onmicrosoft.com header.s=selector1-concurrentrt-com02e header.b=LCL76wmR; 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 26-v6si3790706pgo.169.2018.07.04.10.37.24; Wed, 04 Jul 2018 10:37:38 -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; dkim=pass header.i=@concurrentrt.onmicrosoft.com header.s=selector1-concurrentrt-com02e header.b=LCL76wmR; 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 S1753041AbeGDRf2 (ORCPT + 99 others); Wed, 4 Jul 2018 13:35:28 -0400 Received: from mail-eopbgr690126.outbound.protection.outlook.com ([40.107.69.126]:13760 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752950AbeGDRfZ (ORCPT ); Wed, 4 Jul 2018 13:35:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=concurrentrt.onmicrosoft.com; s=selector1-concurrentrt-com02e; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oWbbXUOGQcvWHLjLkqhuB5dgwIyboeokdxdRofgI5D0=; b=LCL76wmRLhiyPk9UvR3phYj5AkQNYbZfIYGdHyuVqtKQ0FP3pY0+g7S8NNr70CAhbAuTuT171K3ThzOss0GHW4FfHVcvfZtP+mR15jGdZRK1MvD5QBOWr627O3zxLcLcXcO50xXMi0Wh/ounIxQRVg/TTERr96lig1sW07qeVi4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Joe.Korty@concurrent-rt.com; Received: from zipoli.concurrent-rt.com (12.220.59.2) by DM6PR11MB2570.namprd11.prod.outlook.com (2603:10b6:5:c6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.24; Wed, 4 Jul 2018 17:35:22 +0000 Date: Wed, 4 Jul 2018 13:35:19 -0400 From: joe.korty@concurrent-rt.com To: Julia Cartwright Cc: tglx@linutronix.de, rostedt@goodmis.org, linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RT] sample fix for splat in futex_[un]lock_pi for !rt Message-ID: <20180704173519.GA24614@zipoli.concurrent-rt.com> Reply-To: "Joe Korty" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) X-Originating-IP: [12.220.59.2] X-ClientProxiedBy: BN6PR02CA0033.namprd02.prod.outlook.com (2603:10b6:404:5f::19) To DM6PR11MB2570.namprd11.prod.outlook.com (2603:10b6:5:c6::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4fb2ce6e-5ce1-4f6a-317c-08d5e1d485ac X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:DM6PR11MB2570; X-Microsoft-Exchange-Diagnostics: 1;DM6PR11MB2570;3:nCm+NXQiQ2DGqoADOYioqDW8+1FHzCbLk2PodF1OjAZYljDlYDMGnzHMoHiJWEwGb8/vyS5CMziMeUxa4CTqA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xVLNE7Vcf2MYPJkVTVqHkIO4oUVLf8XysbWPerSINxiah/F+A21S99O+0fA5/nAoPqgT1p34usflhTaNeHUGKXaSWU8Ed+Kr8qdgTW1Q4dsxhEVcVI/+bYNE3eJ/0NtNwX6z6pHDY7YnMHv9VkZMQ9Ym3f3bKYVH6SCso=;4:7rLDXGmD+wECMxHTDYer4IoztWAy+1HnYwKvrCEhSj2TiG6XTy/ZimvnpXzpE6q+pXzu2iplxd6GTt09qwGpTTrGjCcApZ9owu4VQhQAW8uRDExfgHmNumhlmVJiEOhAN+RBKdFZWpqaQfBtsBhz1hy8ej4JS1yWyT7u7S8DzjWOrRJ67QCD9UutMvh4BmdYMhX/hzIilujNuSfp1iV3As5gQYa2b9bpfhp/7AmvuOrWGJJMbuyxHlsBfbwKSP+ukX2uZ9mHGmNlm8+RLuNXfQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:DM6PR11MB2570;BCL:0;PCL:0;RULEID:;SRVR:DM6PR11MB2570; X-Forefront-PRVS: 0723A02764 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39840400004)(396003)(346002)(366004)(136003)(376002)(199004)(189003)(486006)(6916009)(8936002)(47776003)(16586007)(97736004)(68736007)(50466002)(58126008)(6666003)(33656002)(316002)(5660300001)(7736002)(305945005)(81156014)(81166006)(4326008)(69596002)(25786009)(8676002)(52116002)(7696005)(66066001)(2906002)(386003)(3846002)(26005)(1076002)(6116002)(16526019)(55016002)(186003)(14444005)(9686003)(23726003)(956004)(43066004)(476003)(53416004)(85782001)(478600001)(106356001)(72206003)(105586002)(86362001)(53936002)(18370500001)(85772001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM6PR11MB2570;H:zipoli.concurrent-rt.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: concurrent-rt.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM6PR11MB2570;23:0YEdPaOxkUplGK9Sq/83F31lUU0CNjADjqRgPIcJ2?= =?us-ascii?Q?8mBXOIkACNPRlP2KfHi6wLpKTAAb9Z14roS5dKQYUR1P/lcWFb2ThtVGLmaT?= =?us-ascii?Q?fQa/YeXcP4S9LFKT+UibJj81Ztdu6wl8PqUsDbtwNpl0XOTb0LWNNtqY0EVM?= =?us-ascii?Q?g+yMVw9AacJyW/oeKJp/yZNTwvlhxHOplDcujZmVk9obm9EszgD38/UWVemO?= =?us-ascii?Q?MLid5jeshGX/2Bi97OGhgBr4PSFtUlEXmZiKCoZu+uFh2HkFX0Z1Tsnz1x9G?= =?us-ascii?Q?cj67iKZru83fgg/WyO39aVSOdpqDhkz29c9xeB4ZwVMrW6T3vwv7N9cbmcRi?= =?us-ascii?Q?6zfXy3QNQ4/La6qHCFAlSB7EFDI29SSH05z/iH9mEYv2Ek8GTf9XUTukAu0v?= =?us-ascii?Q?c04ujItZxiMyUQLwxOduLRbNgl9KRskjkaDcN5fkWYuGTYORD2tCpIErubr4?= =?us-ascii?Q?HQ54eVnBBOjLr9wBG2cXaCjnY4VFyUH+y8nFHYPAM2YKdXIqVe2AV2eYi1Fp?= =?us-ascii?Q?46yImFow5b9bioCf0r/amz0eOTgfZW+6Elq195ugfdryNrcc2nGhYqs66oAM?= =?us-ascii?Q?La1TIp2dxSPrqhrN3WZNyZBkTSKsseRNw6rqHuKcdHt5K4WsXO4igkGchV76?= =?us-ascii?Q?+ymu0LoIkwjO1LX7Q0IlLlvfSyHve4msHLjkSm5+eq5hdXdh5rDEuB3DlJ4c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JiCmD1SFKSL9Y5fJGWssynZGb34h77I8Ioo7CH74VGLNdsUmTD3gARlntG2ZOIZu5I1LtUrpFRCORaYv7 X-OriginatorOrg: concurrent-rt.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2018 17:35:22.9470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fb2ce6e-5ce1-4f6a-317c-08d5e1d485ac X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38747689-e6b0-4933-86c0-1116ee3ef93e X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2570 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Balance atomic/!atomic migrate_enable calls in futex_[un]lock_pi. The clever use of migrate_disable/enable in rt patch "futex: workaround migrate_disable/enable in different" has balanced atomic/!atomic context only for the rt kernel. This workaround makes it balanced for both rt and !rt. The 'solution' presented here is for reference only. A better solution might be for !rt to go back to using migrate_enable/disable == preempt_enable/disable. This patch passes the futex selftests for rt and !rt. Sample kernel splat, edited for brevity. This happens near the end of boot on a CentOS 7 installation. WARNING: CPU: 1 PID: 5966 at kernel/sched/core.c:6994 migrate_enable+0x24e/0x2f0 CPU: 1 PID: 5966 Comm: threaded-ml Not tainted 4.14.40-rt31 #1 Hardware name: Supermicro X9DRL-3F/iF/X9DRL-3F/iF, BIOS 3.2 09/22/2015 task: ffff88046b67a6c0 task.stack: ffffc900053a0000 RIP: 0010:migrate_enable+0x24e/0x2f0 RSP: 0018:ffffc900053a3df8 EFLAGS: 00010246 Call Trace: futex_unlock_pi+0x134/0x210 do_futex+0x13f/0x190 SyS_futex+0x6e/0x150 do_syscall_64+0x6f/0x190 entry_SYSCALL_64_after_hwframe+0x42/0xb7 WARNING: CPU: 1 PID: 5966 at kernel/sched/core.c:6998 migrate_enable+0x75/0x2f0 CPU: 1 PID: 5966 Comm: threaded-ml Tainted: G W 4.14.40-rt31 #1 Hardware name: Supermicro X9DRL-3F/iF/X9DRL-3F/iF, BIOS 3.2 09/22/2015 task: ffff88046b67a6c0 task.stack: ffffc900053a0000 RIP: 0010:migrate_enable+0x75/0x2f0 RSP: 0018:ffffc900053a3df8 EFLAGS: 00010246 Call Trace: futex_unlock_pi+0x134/0x210 do_futex+0x13f/0x190 SyS_futex+0x6e/0x150 do_syscall_64+0x6f/0x190 entry_SYSCALL_64_after_hwframe+0x42/0xb7 This patch was developed against 4.14.40-rt31. Should be applicatible to all rt releases in which migrate_enable != preempt_enable for !rt kernels. Signed-off-by: Joe Korty Index: b/kernel/futex.c =================================================================== --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2838,7 +2838,14 @@ retry_private: spin_unlock(q.lock_ptr); ret = __rt_mutex_start_proxy_lock(&q.pi_state->pi_mutex, &rt_waiter, current); raw_spin_unlock_irq(&q.pi_state->pi_mutex.wait_lock); +#ifdef CONFIG_PREEMPT_RT_FULL migrate_enable(); +#else + /* !rt has to force balanced atomic/!atomic migrate_enable/disable uses */ + preempt_disable(); + migrate_enable(); + preempt_enable(); +#endif if (ret) { if (ret == 1) @@ -2998,7 +3005,14 @@ retry: /* drops pi_state->pi_mutex.wait_lock */ ret = wake_futex_pi(uaddr, uval, pi_state); +#ifdef CONFIG_PREEMPT_RT_FULL + migrate_enable(); +#else + /* !rt has to force balanced atomic/!atomic uses */ + preempt_disable(); migrate_enable(); + preempt_enable(); +#endif put_pi_state(pi_state);