From patchwork Thu Apr 9 15:15:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Belits X-Patchwork-Id: 221313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D24FFC2BA2B for ; Thu, 9 Apr 2020 15:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 975EE2078E for ; Thu, 9 Apr 2020 15:16:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="d7XLeGfU"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="GgGRiAbg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbgDIPQ3 (ORCPT ); Thu, 9 Apr 2020 11:16:29 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:17848 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727855AbgDIPQ3 (ORCPT ); Thu, 9 Apr 2020 11:16:29 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 039FFXVk014764; Thu, 9 Apr 2020 08:15:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=QWu2M76m9hVSAXAAtmF1o1VVMW+6Oofv940UBtiP6Bs=; b=d7XLeGfUM1m7K618JK++g7W7UXJ+XWAvNSmd+pwohBeLpfKu+N7rnV5Fbr4vhfCK8SAz Zo17mHkKpWv6cuLKgK4w2Q7HJ4gkhC532bBb4mSu59OMS360vjKE/9ijNHKiep7XO0tK NsVjFrQsnu37+c1XBz/Kczs/4R0xglsx0YVGopfcndWPhVs2PtpCJAcmGZnPPv+GkVCG MIRvrATv8BrSKCIBbOz70uwVciuPMt/2O6Yh2ZzRYxJB2ohYh1X2OMT+Yd7oNjiqqkjB H9AdWBvhvSVtAfSSc3AbAGX1SACp6tQOss3619vUj1qRD9P4DuHNHjvaQtIQKYAC1SR6 Hg== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3091jwh01r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Apr 2020 08:15:46 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:15:44 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:15:43 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.103) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 9 Apr 2020 08:15:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ek5TuMsiUSRAlc7kJhdHLHK8nGltkIeB8G1xfCHP7jiLyj0iqCSWAKDg/i+lxv4+4+Bk8g06NvHIJNF/QuJ7mgAhGE/0axsKm/GdzlgCeJnT4zntONMUj2aKxSs8HUhRQa5nnHTclXZb1UQWg+Xw2QB5ZGzfsUIdy5kQAVVwIHnPxZ8V8HRtNS8OWSAYR/rJjBJnn5BI/wwaPdSD65OMPwkHpnDPLVRX3Ds/Fm2gsJ2GPc5wZ5QDPzoBWQr2DBw73y0KptA2nLRXUtZ7OAFcrTdnU5ed9d7r85AGm4ef3923uBGGpYTsQAT5hw4H/nmk35PcTDxCg7sruwQ43VXGdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QWu2M76m9hVSAXAAtmF1o1VVMW+6Oofv940UBtiP6Bs=; b=DBM/Sco5QhdOi1rNmPB85+rDn8IvPj3j3i8+kpiCtOhJYV3xScAlM+P1vVn3DLP55cznmAnFBTSyJkRMsBshj/15UFuvIgbrQJmoIVhjBCa/2ICwr3CUXXlG3s0SvlBC+g0K6T3iYXUlhPPAHhE+ytvVQYf4WDvCiXjcOdB0R0Vw+jvlN9MCSDOL4NtizhiM3o2/dukA6Ndqda9vRt4WDSfYpzdhcOcolJRILEInN6fEi7wwudqW451VzWw7x/i9qXbil2pq0xWGE4/w7Lhq4qC4HmZvFlZiu3fipj6S54x+xw5GPgWYW1f1VEVQ9n/9KFkR3NZzDKcDTNPt44SvDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QWu2M76m9hVSAXAAtmF1o1VVMW+6Oofv940UBtiP6Bs=; b=GgGRiAbg69eJwWEGUBUIjzwWmizNfoJ7v3f3Oq/jHK2/ajKL8IjdfkIlwIcT8klX/41xLCYu92d+K5l5K1CZl3wT+GRlYR2qcvXF5EbJjum9GgM+6t37ZHWQqx+emeHsXehUbkwyb7E73J2bByGMW2W16ytQeVs81FkUndGNdoQ= Received: from BYAPR18MB2535.namprd18.prod.outlook.com (2603:10b6:a03:137::17) by BYAPR18MB2758.namprd18.prod.outlook.com (2603:10b6:a03:112::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.18; Thu, 9 Apr 2020 15:15:42 +0000 Received: from BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280]) by BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280%3]) with mapi id 15.20.2878.022; Thu, 9 Apr 2020 15:15:42 +0000 From: Alex Belits To: "frederic@kernel.org" , "rostedt@goodmis.org" CC: Prasun Kapoor , "mingo@kernel.org" , "davem@davemloft.net" , "linux-api@vger.kernel.org" , "peterz@infradead.org" , "linux-arch@vger.kernel.org" , "catalin.marinas@arm.com" , "tglx@linutronix.de" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: [PATCH 01/13] task_isolation: vmstat: add quiet_vmstat_sync function Thread-Topic: [PATCH 01/13] task_isolation: vmstat: add quiet_vmstat_sync function Thread-Index: AQHWDoG87dqkhBWgL0Cw8QsE6xEP5A== Date: Thu, 9 Apr 2020 15:15:42 +0000 Message-ID: References: <4473787e1b6bc3cc226067e8d122092a678b63de.camel@marvell.com> <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> In-Reply-To: <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 283ce317-d806-4a32-2928-08d7dc98ded4 x-ms-traffictypediagnostic: BYAPR18MB2758: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1186; x-forefront-prvs: 0368E78B5B x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR18MB2535.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(39860400002)(366004)(396003)(136003)(376002)(346002)(478600001)(36756003)(7416002)(71200400001)(2906002)(186003)(26005)(86362001)(2616005)(316002)(6506007)(110136005)(54906003)(64756008)(66556008)(6486002)(8936002)(66946007)(66476007)(4326008)(5660300002)(66446008)(6512007)(8676002)(81166007)(76116006)(81156014); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OkwhCHAY5goLA0fQmiM6TetQYIglVy7xWFOKhXivynbLClOQ3oSc7jUexvvEVtl0BeNMUB41/+QsbfTgSYd7yshdAKeK5N85vVL5Jz4ug0e1biHvEAbwPgnhLZ8nGMS54LHBIOmnuSn3h+eVtis6MZlSAkAntYISlagyHl0OmJXmymvHIwars335/uoVvT/7zxOSaMzSSigO8Y+z6jsVbj3Ha7DEdV1YprNmsh2YvhkYqqXFlraS+szYPkLuyO0lvSc6wN31hbXYojoUyquH7AkrQpnm5Z4kXOhwAbls8Ln/eYMJbzvdFrq9QlxfI/tKS4G0LmCPivYGE8STIReWGNMzUD5i3w+ceNaRHX0CCA/p/oQQVSv5jR27eFwbMa13mRIbaf+98kYODci+3xFaeNFayiCjGSrk62QjPDbvYIhiWyPrlEaf4ri9cdcBTqa4 x-ms-exchange-antispam-messagedata: rpSTL6Qw1A2IO3ff98dfyXjfnCGP0IVkVLdkFM/N3oqbIxV/UhcW5lwVJTs0FTV+UYhH8/IIp/6Uu07rPz9L2ziIn74rXXwnghxaev4hboLMbKqmjXfalsuCrlA+XlbgQLwFl1okGvVfIQzwYSLjNw== Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 283ce317-d806-4a32-2928-08d7dc98ded4 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2020 15:15:42.6311 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8u8TVyVD7tNTSHD8Owz+u3APJ5DFMVfstqYsxbm9MB1J2iyaX7/ob1DIUJBgCwRHzy15Kow9OrQXcDuoxHmcfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2758 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-09_05:2020-04-07,2020-04-09 signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In commit f01f17d3705b ("mm, vmstat: make quiet_vmstat lighter") the quiet_vmstat() function became asynchronous, in the sense that the vmstat work was still scheduled to run on the core when the function returned. For task isolation, we need a synchronous version of the function that guarantees that the vmstat worker will not run on the core on return from the function. Add a quiet_vmstat_sync() function with that semantic. Signed-off-by: Chris Metcalf Signed-off-by: Alex Belits --- include/linux/vmstat.h | 2 ++ mm/vmstat.c | 9 +++++++++ 2 files changed, 11 insertions(+) -- 2.20.1 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 292485f3d24d..2bc5e85f2514 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -270,6 +270,7 @@ extern void __dec_zone_state(struct zone *, enum zone_stat_item); extern void __dec_node_state(struct pglist_data *, enum node_stat_item); void quiet_vmstat(void); +void quiet_vmstat_sync(void); void cpu_vm_stats_fold(int cpu); void refresh_zone_stat_thresholds(void); @@ -372,6 +373,7 @@ static inline void __dec_node_page_state(struct page *page, static inline void refresh_zone_stat_thresholds(void) { } static inline void cpu_vm_stats_fold(int cpu) { } static inline void quiet_vmstat(void) { } +static inline void quiet_vmstat_sync(void) { } static inline void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset) { } diff --git a/mm/vmstat.c b/mm/vmstat.c index 78d53378db99..1fa0b2d04afa 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1870,6 +1870,15 @@ void quiet_vmstat(void) refresh_cpu_vm_stats(false); } +/* + * Synchronously quiet vmstat so the work is guaranteed not to run on return. + */ +void quiet_vmstat_sync(void) +{ + cancel_delayed_work_sync(this_cpu_ptr(&vmstat_work)); + refresh_cpu_vm_stats(false); +} + /* * Shepherd worker thread that checks the * differentials of processors that have their worker From patchwork Thu Apr 9 15:17:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Belits X-Patchwork-Id: 221312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78914C2BBC7 for ; Thu, 9 Apr 2020 15:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E7582074F for ; Thu, 9 Apr 2020 15:18:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Kc94aWrl"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="sfGOb5qo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbgDIPSY (ORCPT ); Thu, 9 Apr 2020 11:18:24 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:17022 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbgDIPSY (ORCPT ); Thu, 9 Apr 2020 11:18:24 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 039FGrOm019691; Thu, 9 Apr 2020 08:17:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=kZ2+j0FCzkWqNio6rCPrs7enWlq6NYbcuZo1CoUS2GQ=; b=Kc94aWrlfz0KrcCajAThCRyZax+qV77EhqG68kHApX4VYvxR1OH0ggcZ+PG5M7NUxIbX 8urkkm0P4aUVxNSQe9/ZihHSL+8vGXISDj5+sd/mbtbHSPjMFCVXSTd3hJJI518Vtd7x OxAlZPN2zBFvaUnlZq/fcCmPp041n/W7gCN1DzZHQIBqJleVebwDr67XsWH9QaA3n0lA 2fi7z5V5BqvTTQ1IN5OEmqmFGQh0vX+F69amx+5eRVnBDmeB/hR5cHXZlY35GhwFKI00 Mlo5I5pgnpgTVrsYE8Hxrz5Y8lSIIJqtQi0ZnMz7V1A8TDDU1ODyudRKHXTdya+GMbdb cA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3091me8y58-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Apr 2020 08:17:43 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:17:41 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.107) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 9 Apr 2020 08:17:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gSuTPqzcO3FdRszOiqJFCb4/R46kRs0DMNgNyQpex3GiSEPdKhBcDVmByOO1zUsrXtdklh80sW/9fg/wEZR41a9j6s2zjMo2JNxOmrCsaOrzV6gW1sB2oGJoR53u3Mn6EwlQIz851wGIuHiIb9utVqGqMubNoTy0yK+rEj2D64Ie5qcRM5VB5IAci0pLL+rbhrNWCB4+92pyC+5stXLknJMk6uDO5H8Add7XiWnVJI1HTkDpR6Di0yVn4H0lyNSLJVdA4PDwyvPrzaj5pwm1swV4Q4c3HgYpTFxHtCtILkvnFkyhETjuSJGI1AkgtiiQgui139ackrS5wYgd317CQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kZ2+j0FCzkWqNio6rCPrs7enWlq6NYbcuZo1CoUS2GQ=; b=WvoNSrliSluATuBJ18+QokXB0i9FyBDAaa0Z8uK6hzyif/kUU1iBYoYvKZwObAz0wim/M2aMbXtTgx/pX8l6jOAxUq4LVB/Vo4FuTEmDdE8Uxvfr8gUQsj+/zWUJ2kfQ98YyChrPdLdNaWwxPagySk+cWoQaDefMricmqav2IL9ghTLwgDjZEjnWeXwNAZ9ogQ8CHR6WPkmzCvx+q9T0pMzcZrHEoyjVO85FTgnkGD7h8Y07u2PlIXAby+ojp+T917as1OfInkZ5QJl6BgNDSsJh2DO0sur201fIlQMowyDHZd7bbM2vfGEzi/KIhOq6Tf/U4Rzle3mX0kbueZ5oyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kZ2+j0FCzkWqNio6rCPrs7enWlq6NYbcuZo1CoUS2GQ=; b=sfGOb5qoCEnzYa/fCbPmRauBX/6FCvd5fpADnmDvfey0HttKvHsQSh03dspYFBiOSKj+VD4PG/b4xESCs8p9iMlsq61N/5NScabJPtb+fUw4Z9GSPh2p9+7E5SYOCqUEPr9Gacko9d1QVWbpHV+3PYdVk4Ja64C6/rochgDZ8+Q= Received: from BYAPR18MB2535.namprd18.prod.outlook.com (2603:10b6:a03:137::17) by BYAPR18MB2758.namprd18.prod.outlook.com (2603:10b6:a03:112::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.18; Thu, 9 Apr 2020 15:17:40 +0000 Received: from BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280]) by BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280%3]) with mapi id 15.20.2878.022; Thu, 9 Apr 2020 15:17:40 +0000 From: Alex Belits To: "frederic@kernel.org" , "rostedt@goodmis.org" CC: Prasun Kapoor , "mingo@kernel.org" , "davem@davemloft.net" , "linux-api@vger.kernel.org" , "peterz@infradead.org" , "linux-arch@vger.kernel.org" , "catalin.marinas@arm.com" , "tglx@linutronix.de" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: [PATCH v3 03/13] task_isolation: add instruction synchronization memory barrier Thread-Topic: [PATCH v3 03/13] task_isolation: add instruction synchronization memory barrier Thread-Index: AQHWDoICUCw40vC9nkuNpTFu2Vf0Xg== Date: Thu, 9 Apr 2020 15:17:40 +0000 Message-ID: References: <4473787e1b6bc3cc226067e8d122092a678b63de.camel@marvell.com> <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> In-Reply-To: <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f48ac113-0493-42dc-d74a-08d7dc992507 x-ms-traffictypediagnostic: BYAPR18MB2758: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1303; x-forefront-prvs: 0368E78B5B x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR18MB2535.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(39860400002)(366004)(396003)(136003)(376002)(346002)(478600001)(36756003)(7416002)(71200400001)(2906002)(186003)(26005)(86362001)(2616005)(316002)(6506007)(110136005)(54906003)(64756008)(66556008)(6486002)(8936002)(66946007)(66476007)(4326008)(5660300002)(66446008)(6512007)(8676002)(81166007)(76116006)(81156014); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1UPrewe9j5MkY+wG/WKajqXFVDTnUiTHFMhogoclXy0Rw/5moqUaZ5jCOSkPCfSINsK3k73LcFWKobQkCbjbeA4KiB3hndNDDdwWaG7BYshR5Tz0Sv0pE/bJ5C0wAh3lfckuoQzrzwwrj2JSdSXOvYlfzYzI2InWyr8EjNsR+0unUv4EaGF33fciOSoRJ0VmxdBwBn4mOnFv3YBl8dN8cOTrsYteihDjkgQyOTFuRBYqwVA4Z+lZCkdBBiSGVxZPmUemwQ2Angf925SJZzAuDrPs5Jn8q0FPlQNC4wp/vjMIuS7aiRx6gJm2r+SDn3CF0nsw19oQ5tEL8MN/E58qHfAO2EPiuvlaXox3sY9mEhtcM1V4BEejq4uGdTwdb1POruFSZh1mUo2cZN8lD8S+MeLZIQ4YowWhuPqR60d/lA+KaxKajNivYISa61ZsdJwt x-ms-exchange-antispam-messagedata: 0o8qkoLBk/b1R3YpNyeGdgB8rpVkEHsucY6QTU9XECOwnAeKLsjq8jDAc6JLtVm4nvujBXjDG8aq3nREQ8bzgbZne5itngwLnDTxI5ES16p+BQQyhoG1Wy+RY9fRcQtht6AgPU2eTIYUfRGYugibOg== Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f48ac113-0493-42dc-d74a-08d7dc992507 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2020 15:17:40.4002 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W3KXvRHORmUTmHCt1fRAQvcViE7LPxCbEhHIEFOke9o+mCnnWbZxxGws1+KrZHRdhNqBTtPQy7og592j5gd6Ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2758 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-09_05:2020-04-07,2020-04-09 signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some architectures implement memory synchronization instructions for instruction cache. Make a separate kind of barrier that calls them. Signed-off-by: Alex Belits --- arch/arm/include/asm/barrier.h | 2 ++ arch/arm64/include/asm/barrier.h | 2 ++ include/asm-generic/barrier.h | 4 ++++ 3 files changed, 8 insertions(+) -- 2.20.1 diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h index 83ae97c049d9..6def62c95937 100644 --- a/arch/arm/include/asm/barrier.h +++ b/arch/arm/include/asm/barrier.h @@ -64,12 +64,14 @@ extern void arm_heavy_mb(void); #define mb() __arm_heavy_mb() #define rmb() dsb() #define wmb() __arm_heavy_mb(st) +#define imb() isb() #define dma_rmb() dmb(osh) #define dma_wmb() dmb(oshst) #else #define mb() barrier() #define rmb() barrier() #define wmb() barrier() +#define imb() barrier() #define dma_rmb() barrier() #define dma_wmb() barrier() #endif diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h index 7d9cc5ec4971..12a7dbd68bed 100644 --- a/arch/arm64/include/asm/barrier.h +++ b/arch/arm64/include/asm/barrier.h @@ -45,6 +45,8 @@ #define rmb() dsb(ld) #define wmb() dsb(st) +#define imb() isb() + #define dma_rmb() dmb(oshld) #define dma_wmb() dmb(oshst) diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h index 85b28eb80b11..d5a822fb3e92 100644 --- a/include/asm-generic/barrier.h +++ b/include/asm-generic/barrier.h @@ -46,6 +46,10 @@ #define dma_wmb() wmb() #endif +#ifndef imb +#define imb barrier() +#endif + #ifndef read_barrier_depends #define read_barrier_depends() do { } while (0) #endif From patchwork Thu Apr 9 15:21:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Belits X-Patchwork-Id: 221311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44507C2BBC7 for ; Thu, 9 Apr 2020 15:22:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A67D2078E for ; Thu, 9 Apr 2020 15:22:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="h85xF34Q"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="lUKNE+a7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728158AbgDIPWL (ORCPT ); Thu, 9 Apr 2020 11:22:11 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:29590 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727978AbgDIPWL (ORCPT ); Thu, 9 Apr 2020 11:22:11 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 039FFXmj014772; Thu, 9 Apr 2020 08:21:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=MTd/dMc3M0TGfoAmo6csx6t6wKErRI+/1qrvWpMK/To=; b=h85xF34Q1ThdNqX8B36c0NHLOjXuGyA/NiTGDrbGNM0nyUHcmuxo7Q97ZYIH66whqtPj 6HJ1BAq6heHTuP7Vr+xOuI7nKqCR0/AygvtNkPCm5uLNqlKqZaGj1KcmW4tjLZXcGp+u 6MAE1OCDCVAjO5pWsYjMcKZ8axfTwlUh9rXqrsepy061LAaHby0SlGf38+o1IFXAsqDG GSwzKe0eCDdxp32+Af2AFnIeLbRjLMEQlBEMJO8bKAr/oin56CEV7cEHhhhahqcFnLyL MkPYixoORrThD/PMlmk2DCb3zra0WPxIAiaIMpAxk3VWnG/6dz9IhujiEbfpamXenGM8 sQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3091jwh0sx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Apr 2020 08:21:43 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:21:42 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (104.47.37.50) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 9 Apr 2020 08:21:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nsVWlJOt9lyHRcX3OkT/iGpfaw9ShTnyvZ8DK//bl9sL0hI87aosr6u/sdTTZOv52mpHjeYiEhl2OMBuzCznHd2VN6YdEtjYLA+IQNcLlwKmdHR1R62yLx2eIs1pYXIvzybOuJmSnMbiN/+IAcVqVNM1XrPrzKxFpNT2hnftWnE+BHBFdouLDWAzatEUwNjD1dH5Dq+T3o/eDSCFxzjiK506MCpiOsJUPBdqAKi9BLk8w1g+lDvHgKVtanmREdSAsAXK9fM/wKNJ4RJ/yNPBhGc/IjKqZSsTbeifUvamAXE2eY7JM2XJ5QQQiHSidLFmpf2Fz1h9TyC5GzMsH8E5Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MTd/dMc3M0TGfoAmo6csx6t6wKErRI+/1qrvWpMK/To=; b=WzpK/VEZ0iFqT/3uqKd6jkfiGifa6tfnAvo5dB3VBqv51mlHgQ/rRpzfIDXGaB8UTdlq/GWAxBbAHz0wEnGZyehK9KG8XqQoeuW20QhGN8+6CqBGmg74ushWlmCs1dMAoS89K2xn7fSMdJqpehz4bcTabtmwllXpQ9zMPPpe1q6jK8k923HBlGQpgntzNSrg6KUFUZpN97X3f6gTrT57xOMuns/wv8wNgmhDJ8tbLJ6RxEtxPwFO2wQp+CfdgXME1V8B2RHwRMhhhsg7485Oh3n7M7d3a0lSeKJBAcqSi8vG0KHyg2Bo5QuWjypTtJZCG9nmZweDWQy2IkRO9mUlbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MTd/dMc3M0TGfoAmo6csx6t6wKErRI+/1qrvWpMK/To=; b=lUKNE+a7Rt5nAgSbI6ooNnfommWghvjbq4/vlnCXNnt1HFqTJam1QBhZES+IlZ+xbZn6GpT5zRyH8KeODDH0T4s8YrwWYeaZLgsdhUtAHPHecl4FOPSxB+SkVbjMWBHgj667in8GSmxVBwk+Eusu6a7Wf9HrannLB1WRRja+9lM= Received: from BYAPR18MB2535.namprd18.prod.outlook.com (2603:10b6:a03:137::17) by BYAPR18MB3749.namprd18.prod.outlook.com (2603:10b6:a03:96::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.20; Thu, 9 Apr 2020 15:21:41 +0000 Received: from BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280]) by BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280%3]) with mapi id 15.20.2878.022; Thu, 9 Apr 2020 15:21:41 +0000 From: Alex Belits To: "frederic@kernel.org" , "rostedt@goodmis.org" CC: Prasun Kapoor , "mingo@kernel.org" , "davem@davemloft.net" , "linux-api@vger.kernel.org" , "peterz@infradead.org" , "linux-arch@vger.kernel.org" , "catalin.marinas@arm.com" , "tglx@linutronix.de" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: [PATCH 05/13] task_isolation: Add task isolation hooks to arch-independent code Thread-Topic: [PATCH 05/13] task_isolation: Add task isolation hooks to arch-independent code Thread-Index: AQHWDoKSSgP/4IAd8kmBGtttI7fyjg== Date: Thu, 9 Apr 2020 15:21:41 +0000 Message-ID: <74b9aa603bc03fe572cc4cd51ba2f8e2829b6ed5.camel@marvell.com> References: <4473787e1b6bc3cc226067e8d122092a678b63de.camel@marvell.com> <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> In-Reply-To: <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 32f65b85-03a0-434b-4a42-08d7dc99b4b3 x-ms-traffictypediagnostic: BYAPR18MB3749: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:418; x-forefront-prvs: 0368E78B5B x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR18MB2535.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(346002)(376002)(366004)(396003)(136003)(39860400002)(64756008)(316002)(186003)(26005)(66446008)(81156014)(2616005)(8936002)(66476007)(4326008)(7416002)(54906003)(478600001)(81166007)(6506007)(66946007)(71200400001)(110136005)(86362001)(6486002)(76116006)(8676002)(2906002)(36756003)(66556008)(5660300002)(6512007); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vDsc+kzY9wpsVqgfPN3holtjZEW+QRHAZjnx677yDvNPSSbt8R5cDrOmxOWuhlk4Vgfxv4b8r8W9y41d1q1DAP3Jl1AwX+XDVsqhSjH5JjbBoquJ9ONsffQUpETZMSRefMbbELF6afK/7fZmuIEQkL99uRndqsC6O9jhGje/eAMIEED0Xq46NapJg/V9RQk/MDLuKfb7t7b+cxf/9UTKCW+ZKqCO19dBDPXswELaWF08Ho8D3ntcE3MokJKesCraVNr7UcR2nkTLWZ7exRDZgBAvh8wFUWoYtFhqd9KYES5lcsD5/WmqD0zJs7tTkciNZ8GbB7uPI7QmNKlqlVNzdI7REZnaaLaaUU1e1z+AgVjX4MQ0u0aN10jsxykGJCL/QSVzqO0i+KP6BmdV1dB+NuV4CyICGXRhTEMLw77K0DV+o/kM6zm8pU+/1hGL+9Vy x-ms-exchange-antispam-messagedata: mjCR4yKjm6KgGmV3mzhGcG2pxewJiZOliY28zLL65KM2oHTgz4Q6o0Jip3paUy/mfUfJuU+Z+lLvkIxIbT0GzXzhPcRTJhMH4uJ6BKn+P9AUWnCjb8tUVMEvVdpwIvVKDzW6vsidnnhF28m+EiUR1A== Content-ID: <1E0295570786A34A894120F715BCC68A@namprd18.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 32f65b85-03a0-434b-4a42-08d7dc99b4b3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2020 15:21:41.3522 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: NcTefQ2Tbdr3Z8twXicrgblcJlbHnFQJYiyDk8eG/uhLiys6rFgAeV+RJFzG/53jR5lrVVxm80jqTHBN6Ks9nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB3749 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-09_05:2020-04-07,2020-04-09 signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Chris Metcalf This commit adds task isolation hooks as follows: - __handle_domain_irq() generates an isolation warning for the local task - irq_work_queue_on() generates an isolation warning for the remote task being interrupted for irq_work - generic_exec_single() generates a remote isolation warning for the remote cpu being IPI'd - smp_call_function_many() generates a remote isolation warning for the set of remote cpus being IPI'd Calls to task_isolation_remote() or task_isolation_interrupt() can be placed in the platform-independent code like this when doing so results in fewer lines of code changes, as for example is true of the users of the arch_send_call_function_*() APIs. Or, they can be placed in the per-architecture code when there are many callers, as for example is true of the smp_send_reschedule() call. A further cleanup might be to create an intermediate layer, so that for example smp_send_reschedule() is a single generic function that just calls arch_smp_send_reschedule(), allowing generic code to be called every time smp_send_reschedule() is invoked. But for now, we just update either callers or callees as makes most sense. Signed-off-by: Chris Metcalf [abelits@marvell.com: adapted for kernel 5.6] Signed-off-by: Alex Belits --- kernel/irq/irqdesc.c | 9 +++++++++ kernel/irq_work.c | 5 ++++- kernel/smp.c | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 98a5f10d1900..e2b81d035fa1 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "internals.h" @@ -670,6 +671,10 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, irq = irq_find_mapping(domain, hwirq); #endif + task_isolation_interrupt((irq == hwirq) ? + "irq %d (%s)" : "irq %d (%s hwirq %d)", + irq, domain ? domain->name : "", hwirq); + /* * Some hardware gives randomly wrong interrupts. Rather * than crashing, do something sensible. @@ -711,6 +716,10 @@ int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq, irq = irq_find_mapping(domain, hwirq); + task_isolation_interrupt((irq == hwirq) ? + "NMI irq %d (%s)" : "NMI irq %d (%s hwirq %d)", + irq, domain ? domain->name : "", hwirq); + /* * ack_bad_irq is not NMI-safe, just report * an invalid interrupt. diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 828cc30774bc..8fd4ece43dd8 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -102,8 +103,10 @@ bool irq_work_queue_on(struct irq_work *work, int cpu) if (cpu != smp_processor_id()) { /* Arch remote IPI send/receive backend aren't NMI safe */ WARN_ON_ONCE(in_nmi()); - if (llist_add(&work->llnode, &per_cpu(raised_list, cpu))) + if (llist_add(&work->llnode, &per_cpu(raised_list, cpu))) { + task_isolation_remote(cpu, "irq_work"); arch_send_call_function_single_ipi(cpu); + } } else { __irq_work_queue_local(work); } diff --git a/kernel/smp.c b/kernel/smp.c index d0ada39eb4d4..3a8bcbdd4ce6 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "smpboot.h" @@ -176,8 +177,10 @@ static int generic_exec_single(int cpu, call_single_data_t *csd, * locking and barrier primitives. Generic code isn't really * equipped to do the right thing... */ - if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu))) + if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu))) { + task_isolation_remote(cpu, "IPI function"); arch_send_call_function_single_ipi(cpu); + } return 0; } @@ -466,6 +469,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, } /* Send a message to all CPUs in the map */ + task_isolation_remote_cpumask(cfd->cpumask_ipi, "IPI function"); arch_send_call_function_ipi_mask(cfd->cpumask_ipi); if (wait) { From patchwork Thu Apr 9 15:23:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Belits X-Patchwork-Id: 221310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57DF6C2BBC7 for ; Thu, 9 Apr 2020 15:24:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 143112082D for ; Thu, 9 Apr 2020 15:24:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="C6c/b4FJ"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="DkT1npWB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728220AbgDIPYG (ORCPT ); Thu, 9 Apr 2020 11:24:06 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:27186 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbgDIPYF (ORCPT ); Thu, 9 Apr 2020 11:24:05 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 039FGv0u019699; Thu, 9 Apr 2020 08:23:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=O+bhqr4/bcv5yvmoUmApccrZL//vCN8BtdiyigeXwLc=; b=C6c/b4FJok3IN6wLo7/JE2sXnT+HMaHhAlIgCCWKWOdA0t+BxgDAHRe7R7GbFTpxj5Oi YzrVI4o6kewAyE9fxtcWcfR/ZQM470X5NhkQ+MStib4ezXhMKy+mIkxCxwoOcFGr9U6F 7tY8il/+HDblCFlDk7UBaY8bUvkirlBZ20R3SnWvVbZDjVwyXrMaYKds7KVg1C1ee7JZ 3iCGwaBL9UIuv4Qh9GcIAVrY3x9m8rBA8Aa5MHfoZ/dhPO6Ovy9rLoEYe2TCcr3x5JDv yNhzOcAC0d22otHeXhJFPS0ph47fjkUp8iVHOFi7oJuUaQZ4mgxU5E9YQb9aZzfgly+w Lg== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 3091me8yyb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Apr 2020 08:23:38 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:23:36 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (104.47.37.56) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 9 Apr 2020 08:23:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+/eFRWtRofnOl9//20h60maMBp6NHJxmgDRueM5h7s+E7BWGiauEwLYDd/rVJFkeE/C0jC5WM7dNTjF94xxLcfHVjLnPGxKaC7D5HP12SGGeunHK9VuCocEZDkneyW60DA+Z9szQccvRXcs2BwpJiX/qVARCeNEoqMugmZQd0bg4LUhOiDpWKsQ8KvOG/9axX8juU8fKAWcoUYQbupOfF6oOHhKpw89a1igBOU4/HqPUSa34OkjHvEgZz18JGWFhOKNjmCXbpuNVDcSXodnWMcrOGOA3Zo9TEOvaxRQVUQMbHHc3mmPpVASuVJMoQ7QMMGIilGaoAxX0fLWrciHqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O+bhqr4/bcv5yvmoUmApccrZL//vCN8BtdiyigeXwLc=; b=XIqBbjCMhXMY6/A/cUJZRv+ClGwH7m+bgf9OSBp7rcIaF5mEXmpbADnLRsKS6g8kjZ632WGScMplzoqQ+iB4Vekd/jZo4yg+z8BSUJbSlMIvdTpK28t5SO8ERHl1pNwEre9zYrp3ztjgDuZPFAOoaKR6sAkHo+7NQcCn9f6Phv2+ukcdNrAt6UQ71oWpQKT4XFE4ZeXLDgnpZ4aDVwXULaEN8jcwf94xYaRUJb2zOIanaFim3HNRN7pgr6JEtTBqXYh81oaRmj3cOP1ANZPyCp1mmP3tUhd9AG/r2pmHceEsYpI1glzqhouixtIjm/RPcz5iq4DLzpS9hq3D2pPHXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O+bhqr4/bcv5yvmoUmApccrZL//vCN8BtdiyigeXwLc=; b=DkT1npWBr2BgHF5sUEJ1Ysa5Mt4nLaMniKJkn7zQsCSCAkTKDujVwYKi0555subQXhkRKIltPXvuzR8T55mBjjJmCb3KxoptTaWdi4gqByFlVM8NlX9yBa0Z43SZbn4RoGH0FEVy0UFcEbTuzFyx9NHnH+kR6KWSYvMvz4c+hWA= Received: from BYAPR18MB2535.namprd18.prod.outlook.com (2603:10b6:a03:137::17) by BYAPR18MB3749.namprd18.prod.outlook.com (2603:10b6:a03:96::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.20; Thu, 9 Apr 2020 15:23:35 +0000 Received: from BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280]) by BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280%3]) with mapi id 15.20.2878.022; Thu, 9 Apr 2020 15:23:35 +0000 From: Alex Belits To: "frederic@kernel.org" , "rostedt@goodmis.org" CC: Prasun Kapoor , "mingo@kernel.org" , "davem@davemloft.net" , "linux-api@vger.kernel.org" , "peterz@infradead.org" , "linux-arch@vger.kernel.org" , "catalin.marinas@arm.com" , "tglx@linutronix.de" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: [PATCH v3 07/13] task_isolation: arch/arm64: enable task isolation functionality Thread-Topic: [PATCH v3 07/13] task_isolation: arch/arm64: enable task isolation functionality Thread-Index: AQHWDoLVxkJhaapGUEO4pq/iEVe7CQ== Date: Thu, 9 Apr 2020 15:23:35 +0000 Message-ID: <299c02b268a6438704693ddb77cdcb49f382c0ea.camel@marvell.com> References: <4473787e1b6bc3cc226067e8d122092a678b63de.camel@marvell.com> <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> In-Reply-To: <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9f9158cd-5a7b-4305-cbf7-08d7dc99f887 x-ms-traffictypediagnostic: BYAPR18MB3749: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0368E78B5B x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR18MB2535.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(346002)(376002)(366004)(396003)(136003)(39860400002)(64756008)(316002)(186003)(26005)(66446008)(81156014)(2616005)(8936002)(66476007)(4326008)(7416002)(54906003)(478600001)(81166007)(6506007)(66946007)(71200400001)(110136005)(86362001)(6486002)(76116006)(8676002)(2906002)(36756003)(66556008)(5660300002)(6512007); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dPiCLS+c/IiLxN+TF7GCkf4EixAP+tJ1MAtCODTMbxOycVgPZbyuSFdCMz2RW/9xAZVg4xN7foTK3CKHWAw/U+gUCIhYCOmNifns/AuQfNL/kUzIbmfG6ctQfGPMe9XaoVf9QmkiIjR0eTltkWXBU6SicsZ6/t6RBgBKU3uwvCDAWUqhFd37YaNI4CsDlOkq04stngRSs4bHVPGoMmZqx+K2Im6ry29AQnZ87X40eMEAcAsSYtzjM36y9ZJMt/j71Cc3RlhFNyr1aVVScKT/dGGFRzZ+zSakQoDa27YFjyTC4cTlFREUddNmcJhJZNZOTJ+rCUJqYoUqGaLgc+SDQu63k0b0d2P6BS+nK+GABSVChXurx40QUecB0wjzCrDZxKlHdLdSwKsnOFYp4y4xEA1AuN5o4FBpxhC/oqoq2HCCj5J43P5IMEKQfzDjNkoH x-ms-exchange-antispam-messagedata: bEe51MfCgru3S24MepotIK0PxuBTXF/lE4Tedkf2wsv7nNJNk9s5ATHTcp7ecEeFSPQphSzRd5h5NpF05E3MYDd3bsZ/kfPG0hbRHKOIlLceBEMN8Gm7pAGK3ERpfS29zjPEMz67sIElsKO/r5MLhQ== Content-ID: <9DCFD84EDA53E94BA1A65721B1BFBFB7@namprd18.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 9f9158cd-5a7b-4305-cbf7-08d7dc99f887 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2020 15:23:35.2272 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Xr4o6L4kaaX1GLy31jNSo0uDynaTLcAJfgWAKeu0DZjabJFS8qkROy1EnVSbKDDfgDtFXg7forPT2lWAE6EUcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB3749 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-09_05:2020-04-07,2020-04-09 signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Chris Metcalf In do_notify_resume(), call task_isolation_start() for TIF_TASK_ISOLATION tasks. Add _TIF_TASK_ISOLATION to _TIF_WORK_MASK, and define a local NOTIFY_RESUME_LOOP_FLAGS to check in the loop, since we don't clear _TIF_TASK_ISOLATION in the loop. We instrument the smp_send_reschedule() routine so that it checks for isolated tasks and generates a suitable warning if needed. Finally, report on page faults in task-isolation processes in do_page_faults(). Signed-off-by: Chris Metcalf [abelits@marvell.com: simplified to match kernel 5.6] Signed-off-by: Alex Belits --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/thread_info.h | 5 ++++- arch/arm64/kernel/ptrace.c | 10 ++++++++++ arch/arm64/kernel/signal.c | 13 ++++++++++++- arch/arm64/kernel/smp.c | 7 +++++++ arch/arm64/mm/fault.c | 5 +++++ 6 files changed, 39 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 0b30e884e088..93b6aabc8be9 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -129,6 +129,7 @@ config ARM64 select HAVE_ARCH_PREL32_RELOCATIONS select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_STACKLEAK + select HAVE_ARCH_TASK_ISOLATION select HAVE_ARCH_THREAD_STRUCT_WHITELIST select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index f0cec4160136..7563098eb5b2 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -63,6 +63,7 @@ void arch_release_task_struct(struct task_struct *tsk); #define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */ #define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */ #define TIF_FSCHECK 5 /* Check FS is USER_DS on return */ +#define TIF_TASK_ISOLATION 6 #define TIF_NOHZ 7 #define TIF_SYSCALL_TRACE 8 /* syscall trace active */ #define TIF_SYSCALL_AUDIT 9 /* syscall auditing */ @@ -83,6 +84,7 @@ void arch_release_task_struct(struct task_struct *tsk); #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) #define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE) +#define _TIF_TASK_ISOLATION (1 << TIF_TASK_ISOLATION) #define _TIF_NOHZ (1 << TIF_NOHZ) #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) @@ -96,7 +98,8 @@ void arch_release_task_struct(struct task_struct *tsk); #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \ - _TIF_UPROBE | _TIF_FSCHECK) + _TIF_UPROBE | _TIF_FSCHECK | \ + _TIF_TASK_ISOLATION) #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index cd6e5fa48b9c..b35b9b0c594c 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1836,6 +1837,15 @@ int syscall_trace_enter(struct pt_regs *regs) return -1; } + /* + * In task isolation mode, we may prevent the syscall from + * running, and if so we also deliver a signal to the process. + */ + if (test_thread_flag(TIF_TASK_ISOLATION)) { + if (task_isolation_syscall(regs->syscallno) == -1) + return -1; + } + /* Do the secure computing after ptrace; failures should be fast. */ if (secure_computing() == -1) return -1; diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 339882db5a91..d488c91a4877 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -898,6 +899,11 @@ static void do_signal(struct pt_regs *regs) restore_saved_sigmask(); } +#define NOTIFY_RESUME_LOOP_FLAGS \ + (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ + _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \ + _TIF_UPROBE | _TIF_FSCHECK) + asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags) { @@ -908,6 +914,8 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, */ trace_hardirqs_off(); + task_isolation_check_run_cleanup(); + do { /* Check valid user FS if needed */ addr_limit_user_check(); @@ -938,7 +946,10 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, local_daif_mask(); thread_flags = READ_ONCE(current_thread_info()->flags); - } while (thread_flags & _TIF_WORK_MASK); + } while (thread_flags & NOTIFY_RESUME_LOOP_FLAGS); + + if (thread_flags & _TIF_TASK_ISOLATION) + task_isolation_start(); } unsigned long __ro_after_init signal_minsigstksz; diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index d4ed9a19d8fe..00f0f77adea0 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -818,6 +819,7 @@ void arch_send_call_function_single_ipi(int cpu) #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL void arch_send_wakeup_ipi_mask(const struct cpumask *mask) { + task_isolation_remote_cpumask(mask, "wakeup IPI"); smp_cross_call(mask, IPI_WAKEUP); } #endif @@ -886,6 +888,9 @@ void handle_IPI(int ipinr, struct pt_regs *regs) __inc_irq_stat(cpu, ipi_irqs[ipinr]); } + task_isolation_interrupt("IPI type %d (%s)", ipinr, + ipinr < NR_IPI ? ipi_types[ipinr] : "unknown"); + switch (ipinr) { case IPI_RESCHEDULE: scheduler_ipi(); @@ -948,12 +953,14 @@ void handle_IPI(int ipinr, struct pt_regs *regs) void smp_send_reschedule(int cpu) { + task_isolation_remote(cpu, "reschedule IPI"); smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); } #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST void tick_broadcast(const struct cpumask *mask) { + task_isolation_remote_cpumask(mask, "timer IPI"); smp_cross_call(mask, IPI_TIMER); } #endif diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 85566d32958f..fc4b42c81c4f 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -543,6 +544,10 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, */ if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS)))) { + /* No signal was generated, but notify task-isolation tasks. */ + if (user_mode(regs)) + task_isolation_interrupt("page fault at %#lx", addr); + /* * Major/minor page fault accounting is only done * once. If we go through a retry, it is extremely From patchwork Thu Apr 9 15:25:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Belits X-Patchwork-Id: 221309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16543C2BB86 for ; Thu, 9 Apr 2020 15:26:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D864A2083E for ; Thu, 9 Apr 2020 15:26:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="GNdL6uWv"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="mnPrfBVh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728232AbgDIP0I (ORCPT ); Thu, 9 Apr 2020 11:26:08 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:28256 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727912AbgDIP0I (ORCPT ); Thu, 9 Apr 2020 11:26:08 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 039FPUww025152; Thu, 9 Apr 2020 08:25:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=SAObrDh4BpvmmmMIk906+21KJgLj+iVWSYavS1bfa1g=; b=GNdL6uWvNwBJl+uULPy4Wd6hNu/T1mKt+0EcjpxtHekRy1WOolu1oAMfzW/ShZRFo6ok 48KUHoqrNK2fcj3+hWIrogQwIrHXli1EpJe9qB83eBaxHFdQe7e77dvg3rtE7yMOSB73 izMlayTSgZeqkkmtpR8nLmay2eVLULneeHEFWSmUx8CA0AOawTGIoaf/pWBmPBVyMaZH HO+0HXxBd5HkeKJpBuBa+gmaHHQya5tURIIe/WP17o1Gqt0quB18TcR09Vs7imh6oaB1 1jZs+4lSujFsEHZrK3jaAWuOSxmaDNOam3IueoeK1BDgqwN5gKSbC9Irq9bkQNzRAjO+ Pw== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 3091jwh18r-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Apr 2020 08:25:41 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:25:39 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.105) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 9 Apr 2020 08:25:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SvHE4WUXXx/zVCqTiE0QdVzeEMYvETqO/Mm5WA4rLyBc4xS94oSVLw+9u1MQKpvZS+OwOrHn+mQEj+v5hVTsAZtK0Tl9w8/B/Asf5ONTZ/b2e7xCHG/6Yguk+St4TH+V22QxM+yY+PzjqZoD1S3jR4d+q5J6fsxpnVwAn/IRBBfaZZbMU9dhfwPYeWZz3gCJX5axoh9672/g8HckE8CKcOoFEMv8BiW95TQNsswnqkNHCoE5oauiJ8n34NRMWZlIGwFGcJ6kXAQpysAna+y1GsCep+g5tb1S3hECKeMBsffXYAYyG8mLmUYnDbon/xTRI6sEGb+Cf1qMlnHJ6GW7kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SAObrDh4BpvmmmMIk906+21KJgLj+iVWSYavS1bfa1g=; b=GJkiprLwqVXiVZkVU9C0jwLSAFzDOdaL5gZEo14xJP4v1arw2OUUJ8+xCeI+ePOK0VQfrUHu6JJ+F9z0EvfFRAx+di64nlKMINhkl+CM6qwQAloufxSVyyQc8WJAgwLTb/h77JrSlQS4SQEnmPaRpIfvMrqk/AaVviF7xnj+dbueXK9YxCq6Emnacec3gqa0mcikyZvs726XP+vEzphTIs91p7nxxabTFpl5kAgHOAkQDxV5q2o9vG4aM4iPKHxt4nZ655d1lPkvjI/fL6Z4ji3DUPzGBySNTtc4hd7HhRJMxFjKyEKJ3qCCoM6inJUHA2jnCSCEB6soN2NQlHv/rQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SAObrDh4BpvmmmMIk906+21KJgLj+iVWSYavS1bfa1g=; b=mnPrfBVh6BC4WxATdxArvtNrykdZis6c4avcvHxhrt+MLP5wpKK33O0RbAuyJxaUKJfqQ1xGMCSAEDelDF2dP0uoXunWYP1fAEd5/GtiyHytgGDVA511yfj9ehjg8KtcNW2FrXuM23sIfP3Cp59x+j+Aw1tQLlMdTDWV9YswfQ4= Received: from BYAPR18MB2535.namprd18.prod.outlook.com (2603:10b6:a03:137::17) by BYAPR18MB2423.namprd18.prod.outlook.com (2603:10b6:a03:132::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.17; Thu, 9 Apr 2020 15:25:37 +0000 Received: from BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280]) by BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280%3]) with mapi id 15.20.2878.022; Thu, 9 Apr 2020 15:25:37 +0000 From: Alex Belits To: "frederic@kernel.org" , "rostedt@goodmis.org" CC: Prasun Kapoor , "mingo@kernel.org" , "davem@davemloft.net" , "linux-api@vger.kernel.org" , "peterz@infradead.org" , "linux-arch@vger.kernel.org" , "catalin.marinas@arm.com" , "tglx@linutronix.de" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: [PATCH v3 09/13] task_isolation: don't interrupt CPUs with tick_nohz_full_kick_cpu() Thread-Topic: [PATCH v3 09/13] task_isolation: don't interrupt CPUs with tick_nohz_full_kick_cpu() Thread-Index: AQHWDoMezv9vdBNP0UKJE60niGuu6A== Date: Thu, 9 Apr 2020 15:25:37 +0000 Message-ID: References: <4473787e1b6bc3cc226067e8d122092a678b63de.camel@marvell.com> <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> In-Reply-To: <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dd9a56da-5fd7-4969-82c4-08d7dc9a4166 x-ms-traffictypediagnostic: BYAPR18MB2423: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 0368E78B5B x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR18MB2535.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(366004)(376002)(39860400002)(346002)(396003)(136003)(86362001)(26005)(186003)(5660300002)(316002)(2616005)(81166007)(36756003)(7416002)(71200400001)(2906002)(76116006)(4744005)(6486002)(478600001)(6506007)(6512007)(66556008)(64756008)(66446008)(8676002)(81156014)(66476007)(8936002)(66946007)(54906003)(4326008)(110136005); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: u8lIxSXLq+5FP9v9JHnqyAeolh5Fvh8Vbc8wtR/ZKwKvELXDUxR08Rtr54EaO20ncKIYbQtdXPOSrUMs0Vn0Maaj5mcw6LJG8Pm4NlAf1bqwNPFNQ3BQAIVyRMCLmm1/fdfv+NO9+F/jlMQAP9peOnRu+X+hy9UWlSkRVl4Oq/dQXvra1Xuo8NdO6T+i/sAhKKjIsfDmQiLi81adQunnSaL4RXi9e8YGS5lrVUHMgtmqNLUbq6ML+GwVGFlXB5zv8PsqSgw1NlKLUsDoxW0MxyLcHlL1pPFEGsBrKVXrQuadJTRmtHfmtzoOsksl9zAwnUdrk3SNaeEryHHxKKsdw/oqQxpEkYo86t9NU5Oon7q/lvJfZMAAiN8Xu+4HYrv2yV8tC7NkAy61xWuhO11fnrdWTpTOsQzpVIXENG5MAqCwaeP/KWct6pJmahFEXEeX x-ms-exchange-antispam-messagedata: PVp9uW4Ymz1S8U6GLyvdvFiAqOv0PgoSNl5vnn03WCc6afG94RP3DO3yTOdED7JDOGHGcRCXQyx5y6zBZuF1Fo0Y5lB+4oXfvSWGg9nSTZtL4inZaXJVIh8H+ovQi0uh30ZYWRIdaw4h4KgBu3ZTwQ== Content-ID: <75515075B8A98845BEB0DA9CF39FEF36@namprd18.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: dd9a56da-5fd7-4969-82c4-08d7dc9a4166 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2020 15:25:37.4267 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: g4KQWbzNfvW9YmKek8OD5BCVPKWRmmybLMl5ES8JQmDU3lyE4K+h013+vKp6A60FIHYPyENMsLtSLNTn44FF7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2423 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-09_05:2020-04-07,2020-04-09 signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yuri Norov For nohz_full CPUs the desirable behavior is to receive interrupts generated by tick_nohz_full_kick_cpu(). But for hard isolation it's obviously not desirable because it breaks isolation. This patch adds check for it. Signed-off-by: Yuri Norov [abelits@marvell.com: updated, only exclude CPUs running isolated tasks] Signed-off-by: Alex Belits --- kernel/time/tick-sched.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 1d4dec9d3ee7..8488c2825a45 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -262,7 +263,8 @@ static void tick_nohz_full_kick(void) */ void tick_nohz_full_kick_cpu(int cpu) { - if (!tick_nohz_full_cpu(cpu)) + smp_rmb(); + if (!tick_nohz_full_cpu(cpu) || task_isolation_on_cpu(cpu)) return; irq_work_queue_on(&per_cpu(nohz_full_kick_work, cpu), cpu); From patchwork Thu Apr 9 15:27:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Belits X-Patchwork-Id: 221308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32D35C2BB86 for ; Thu, 9 Apr 2020 15:27:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE0BC2074F for ; Thu, 9 Apr 2020 15:27:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="mcdLy69a"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="Rg4YjOja" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728287AbgDIP1w (ORCPT ); Thu, 9 Apr 2020 11:27:52 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:62058 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728061AbgDIP1w (ORCPT ); Thu, 9 Apr 2020 11:27:52 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 039FOjeH028177; Thu, 9 Apr 2020 08:27:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=brVcye4g04z58XKP8Hd8aUsDk8ICA4yESbMdJf0mZFE=; b=mcdLy69a6xzyd7ZvUooO4izwoUjjUp0y9Nb0vnaUpsScF29LhRbn2sGY0O6dDlCSRFXd i+2M0OOEDh6hVAyqthz8eKSrXqBgk+KbDem7xyOSUWJky13Rlq3098NWn0z8djqTq2az YjIxAX3aQmiA5vKHc09fC4zEqhGXa1dcII6Y+Z52+/0fvhTP2tggE34bubToULI6CMb4 n0qVZq9laJeIWMnbta5U6n00H/3uFFlx93D2SGjbPOxfS9poTXD7mzvrfRLDFo7mzjmC XO78lT3IZup7NU3Dk/ZJNaIyaYAQ695WS6lSEM4/xs2faHT7+1T3fSIRKDZ/Hy4kTsp3 iQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 3091me90bj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Apr 2020 08:27:12 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:27:10 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:27:09 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 9 Apr 2020 08:27:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aQsBpe1CkqBQduYIR7oQhBLQvkL+1D+6NWZOI9lLcTx0AVCEx6KatkgDM7mJy+l7EsZ0VvpmBsE1nU5W9gK8IbVj9e6d2yYsjlKPuhUMwfrvGRqfGE6Ci93KoW2fEnVHlOLN+nBxYDTNalfmQ88mNbjevJYbzPLoy6BTxhFxNPYTF9EGg27zTRXUlxUD4/x7E6lxlIoFx/+PdkTmq52Tc594nK3Xgg1hFHKXPwFm6TTwLy/e+5pAf+bk3j2a1VOaJwZBm7aKQF6Ji0Tu0hE67dtNV4MCMO+QRwQ1ohI/eyaJw4YOMrRGbP1fN7ciwwqgJUTvY/7840bzmqwBs2+PxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=brVcye4g04z58XKP8Hd8aUsDk8ICA4yESbMdJf0mZFE=; b=DmTsiEEoh5QokBuA+NEXOydGMbRXBdfJVMTTiZDYz4OcQWx0p9Qimzx5ig5WtisyXseLv4LzKv3zF79diTtw0K/GpdDoY+GTA4354lzYBkxPOM6UCOAeRiualeQYUNeAmyvLLzELyLmyU08wTd7Q0wvu1qfcCjrFNOqnijbxGw4+MuU9pRAbpjWVzhAONXTA2B2qBcfldKqwNoJW9rTmlPQj1tse90n1lj0rxtVpwVFR9Nteqjm8IXKpUNZPu12UasfT1L3itZWyBiFNnSiFRCwRtjUloSO2oQSM62Pfedt3Mh7HvBiXrnbTVNMyezs6xVC1dRQFz4Czu9qKITJgXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=brVcye4g04z58XKP8Hd8aUsDk8ICA4yESbMdJf0mZFE=; b=Rg4YjOjaRacrl7tM9z9ja0uYGN4gc/yGscvS5O3ShXHJlUed/sA7oZg5gD3jJZbKc8rhY5bekQM9Wfq47EXC+kM0h3CseGoCQXelCLgkOC8+N6sRHXrNocj/wjUkbevmla/rsly3fk+uhucIRoxkDZ+x5dJcN44pUEInDuZABp4= Received: from BYAPR18MB2535.namprd18.prod.outlook.com (2603:10b6:a03:137::17) by BYAPR18MB2423.namprd18.prod.outlook.com (2603:10b6:a03:132::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.17; Thu, 9 Apr 2020 15:27:07 +0000 Received: from BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280]) by BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280%3]) with mapi id 15.20.2878.022; Thu, 9 Apr 2020 15:27:07 +0000 From: Alex Belits To: "frederic@kernel.org" , "rostedt@goodmis.org" CC: Prasun Kapoor , "mingo@kernel.org" , "davem@davemloft.net" , "linux-api@vger.kernel.org" , "peterz@infradead.org" , "linux-arch@vger.kernel.org" , "catalin.marinas@arm.com" , "tglx@linutronix.de" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: [PATCH v3 11/13] task_isolation: ringbuffer: don't interrupt CPUs running isolated tasks on buffer resize Thread-Topic: [PATCH v3 11/13] task_isolation: ringbuffer: don't interrupt CPUs running isolated tasks on buffer resize Thread-Index: AQHWDoNUNKRaaRYWTk+1Q1LXrvxHOg== Date: Thu, 9 Apr 2020 15:27:07 +0000 Message-ID: <8f4a0e780c7443d44d7af29fd29ed541ca506bad.camel@marvell.com> References: <4473787e1b6bc3cc226067e8d122092a678b63de.camel@marvell.com> <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> In-Reply-To: <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5b16547a-afd6-4c36-0692-08d7dc9a772d x-ms-traffictypediagnostic: BYAPR18MB2423: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 0368E78B5B x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR18MB2535.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(366004)(376002)(39860400002)(346002)(396003)(136003)(86362001)(26005)(186003)(5660300002)(316002)(2616005)(81166007)(36756003)(7416002)(71200400001)(2906002)(76116006)(6486002)(478600001)(6506007)(6512007)(66556008)(64756008)(66446008)(8676002)(81156014)(66476007)(8936002)(66946007)(54906003)(4326008)(110136005); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OyJOQlB2lAIYNGF/ofoKa2QH1PRjXAq/vrfgcvPpq6vhbWUT60ddktpgMADmlGhhB9ZgCRzWTfIiwQyt/H+S70cQvvhKylsOHYjevMaWXTjPOpGqKr12ROP0u8E65WKG+iFnlHg9qUEi1SsDEm20vSR1pYHFj1Wqp58CUVTJW/QHet3l1GAL3lQGVLyPbxwqFl/V1c0oKfnQPijEtjMlJs/IdSDBqRAPT4kw7poQ2LlHelQvEt44x8hNYU7AcALyKEHfT4tDKCrTmfMEq1wa5Cbe4SvhJWkLyWPnLN5aJYYEEq3741ZjnRH+NoY8P+8B6umMl0GvPavnWBcOJu3Kh39UHGq3XGZoe9ryBQTOIMS4Qen6W6YFEsDHaCSkTNwOSLwq8uyD0WrWBbvMY6lEzkkKsuuJs45aoKfPLV5Yy/y2QbYLBIiUd+B+XcnW3ON0 x-ms-exchange-antispam-messagedata: MIbUoW2IddncEajEN6GeWc6RN3IicNYtum/iOASTjlRuPhSu3j3yYKuETI4u0WCzEWDkfKjN7CIbTaYMxU96AxoMM2etUwO+CoyO3CW1+awZX7f3Mo1XEQBEyeZwbSY05zxBhiyeUqwkFe/66dxvXQ== Content-ID: <50242532F44D2745B5D6A9FFCD5D8962@namprd18.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 5b16547a-afd6-4c36-0692-08d7dc9a772d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2020 15:27:07.6559 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 9Jjm02+PxVACCzcuZO0yWAK6tKoXjCaSZ5j3VOPxs2Vsch40ht1swEPIDzWQH2lOcw9IaL2YxXTDFY130ZoGjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2423 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-09_05:2020-04-07,2020-04-09 signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yuri Norov CPUs running isolated tasks are in userspace, so they don't have to perform ring buffer updates immediately. If ring_buffer_resize() schedules the update on those CPUs, isolation is broken. To prevent that, updates for CPUs running isolated tasks are performed locally, like for offline CPUs. A race condition between this update and isolation breaking is avoided at the cost of disabling per_cpu buffer writing for the time of update when it coincides with isolation breaking. Signed-off-by: Yuri Norov [abelits@marvell.com: updated to prevent race with isolation breaking] Signed-off-by: Alex Belits --- kernel/trace/ring_buffer.c | 63 ++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 61f0e92ace99..972f26fc3540 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1701,6 +1702,38 @@ static void update_pages_handler(struct work_struct *work) complete(&cpu_buffer->update_done); } +static bool update_if_isolated(struct ring_buffer_per_cpu *cpu_buffer, + int cpu) +{ + bool rv = false; + + smp_rmb(); + if (task_isolation_on_cpu(cpu)) { + /* + * CPU is running isolated task. Since it may lose + * isolation and re-enter kernel simultaneously with + * this update, disable recording until it's done. + */ + atomic_inc(&cpu_buffer->record_disabled); + /* Make sure, update is done, and isolation state is current */ + smp_mb(); + if (task_isolation_on_cpu(cpu)) { + /* + * If CPU is still running isolated task, we + * can be sure that breaking isolation will + * happen while recording is disabled, and CPU + * will not touch this buffer until the update + * is done. + */ + rb_update_pages(cpu_buffer); + cpu_buffer->nr_pages_to_update = 0; + rv = true; + } + atomic_dec(&cpu_buffer->record_disabled); + } + return rv; +} + /** * ring_buffer_resize - resize the ring buffer * @buffer: the buffer to resize. @@ -1784,13 +1817,22 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, if (!cpu_buffer->nr_pages_to_update) continue; - /* Can't run something on an offline CPU. */ + /* + * Can't run something on an offline CPU. + * + * CPUs running isolated tasks don't have to + * update ring buffers until they exit + * isolation because they are in + * userspace. Use the procedure that prevents + * race condition with isolation breaking. + */ if (!cpu_online(cpu)) { rb_update_pages(cpu_buffer); cpu_buffer->nr_pages_to_update = 0; } else { - schedule_work_on(cpu, - &cpu_buffer->update_pages_work); + if (!update_if_isolated(cpu_buffer, cpu)) + schedule_work_on(cpu, + &cpu_buffer->update_pages_work); } } @@ -1829,13 +1871,22 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size, get_online_cpus(); - /* Can't run something on an offline CPU. */ + /* + * Can't run something on an offline CPU. + * + * CPUs running isolated tasks don't have to update + * ring buffers until they exit isolation because they + * are in userspace. Use the procedure that prevents + * race condition with isolation breaking. + */ if (!cpu_online(cpu_id)) rb_update_pages(cpu_buffer); else { - schedule_work_on(cpu_id, + if (!update_if_isolated(cpu_buffer, cpu_id)) + schedule_work_on(cpu_id, &cpu_buffer->update_pages_work); - wait_for_completion(&cpu_buffer->update_done); + wait_for_completion(&cpu_buffer->update_done); + } } cpu_buffer->nr_pages_to_update = 0; From patchwork Thu Apr 9 15:28:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Belits X-Patchwork-Id: 221307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6923C2BB55 for ; Thu, 9 Apr 2020 15:29:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D4C220A8B for ; Thu, 9 Apr 2020 15:29:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="DucDX/JA"; dkim=pass (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="m4iP6B43" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728331AbgDIP3X (ORCPT ); Thu, 9 Apr 2020 11:29:23 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:8738 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728255AbgDIP3W (ORCPT ); Thu, 9 Apr 2020 11:29:22 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 039FOYLa028149; Thu, 9 Apr 2020 08:28:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0818; bh=QqX6DBmhSYAp+Ek6zwjJxp8jOQpdgd0MftEbnabeMYM=; b=DucDX/JAV864Kdmn9zCVlJNFdfcoP4JVFZeSUeZy6l4ZApyx5IqJvefrd65wWMtqEfSl 7EAVGWdegh6ekDxevgVde563ryzjNJxQgx9b3Yzr+PESHjIq0r5BEO3Q2UpCb6WlGzAZ u/mFPMtYJzS8ujpU0/Eo0gJLnnv5n11RLFLbVgF9jRzy1+0Z/C+10D7dXZ9l7Y3Wm3UV aN+w0AIOUOb1XqsnwI8I3yh8K7tJeTn0jXyL/9e0ztbD9pFyU88ofplVBAr9zawy2jlH KYCpqgfti2PuPDipzvNvVqBAEpt0RWohiJDvwEv5VRX3g0RPZmXrIlgccRF/nZJsk3Cg 4g== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3091me90jg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Apr 2020 08:28:56 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:28:54 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 9 Apr 2020 08:28:53 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 9 Apr 2020 08:28:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lhz/7T6vcf060a0D+LfpyW/mf7MBqWD3WEbpKKbv1qn7FvL2jTWGH+x9g0j1LgOx7LOjU0SOdWBs26cbwCf2f6zx4aL6ySsFB6DbDQLMiOWmjYy02tA0lNDYMQ/syHKnC4ZWC44ai43c963vZNqV89PUmbEjji0x7WgRPFifR4PlaNuL3ljTL6oyKfnze4giUlkNgk6sFne+HhkBWe0XRkhm/5rrFTqLWgPdgA9X5Bplh+8gmgj/7CFEn1rj0NQC4Qho+L5JH9PPIi3CZGasmS8jBjkZO31iYrQhYO9YeuupEv652OFf0+OO0dnY7FO+V0Swcutu5BSalmVPOFRiRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QqX6DBmhSYAp+Ek6zwjJxp8jOQpdgd0MftEbnabeMYM=; b=DlLdIrulPaR6+fx8sIMIVebC2SfmcjJwOKB1uzyq0s3Y0eRe/vgJs2CbWJJbVb6wPsLaCIS4VFswEdy0yZJI77JsZLomnzkzCskYaPjfOm50+66IVY6ebzIGS2FBFKs5KG4zUo0+dHEaCuHLvGPLELjE2lbHB4RI+2VzCHUEfFZUYv1ARz3ioQxWGKGHfdOcSzCOi0TRMg6ovHdUCN7VVACzbcjoilGWrjGh12URPtG/Jd6Z7SlMueVNr6tc52rCoODpchWKszC+mFgOQZpRu6o3+IrR8S6f+zfCBtx97bg2cb6WBbJMNYtsV0YNE0yhreR1yAjO5aftJ+c/K0MCpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QqX6DBmhSYAp+Ek6zwjJxp8jOQpdgd0MftEbnabeMYM=; b=m4iP6B43sPl07Z1xTwILhDLEOVgV0zJqTNGF+ZpP+Xp5Kabrct+rw5kzi0wMVZC51WuKXLsHvbnjetI9HfUqQE+OFq2gfl2hR2lhjCdJVRlYtbpqh5wUdQ8ZXfsQ56gd0N+i9jcZ+YGmJgFPPZHyvIez2fwoU3aGdq1UDfH8znA= Received: from BYAPR18MB2535.namprd18.prod.outlook.com (2603:10b6:a03:137::17) by BYAPR18MB2423.namprd18.prod.outlook.com (2603:10b6:a03:132::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.17; Thu, 9 Apr 2020 15:28:51 +0000 Received: from BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280]) by BYAPR18MB2535.namprd18.prod.outlook.com ([fe80::65f8:9bfe:5fa5:1280%3]) with mapi id 15.20.2878.022; Thu, 9 Apr 2020 15:28:51 +0000 From: Alex Belits To: "frederic@kernel.org" , "rostedt@goodmis.org" CC: Prasun Kapoor , "mingo@kernel.org" , "davem@davemloft.net" , "linux-api@vger.kernel.org" , "peterz@infradead.org" , "linux-arch@vger.kernel.org" , "catalin.marinas@arm.com" , "tglx@linutronix.de" , "will@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: [PATCH v3 13/13] task_isolation: CONFIG_TASK_ISOLATION prevents distribution of jobs to non-housekeeping CPUs Thread-Topic: [PATCH v3 13/13] task_isolation: CONFIG_TASK_ISOLATION prevents distribution of jobs to non-housekeeping CPUs Thread-Index: AQHWDoOSzjqvMuhweUS4YcE4nDeiww== Date: Thu, 9 Apr 2020 15:28:51 +0000 Message-ID: <51102eebe62336c6a4e584c7a503553b9f90e01c.camel@marvell.com> References: <4473787e1b6bc3cc226067e8d122092a678b63de.camel@marvell.com> <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> In-Reply-To: <07c25c246c55012981ec0296eee23e68c719333a.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 47cd1aaa-c1da-498b-13db-08d7dc9ab537 x-ms-traffictypediagnostic: BYAPR18MB2423: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3968; x-forefront-prvs: 0368E78B5B x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR18MB2535.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(366004)(376002)(39860400002)(346002)(396003)(136003)(86362001)(26005)(186003)(5660300002)(316002)(2616005)(81166007)(36756003)(7416002)(71200400001)(2906002)(76116006)(6486002)(478600001)(6506007)(6512007)(66556008)(64756008)(66446008)(8676002)(81156014)(66476007)(8936002)(66946007)(54906003)(4326008)(110136005); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BxEyfSMn9UqN+T3zfq77zP0QjOLJkGWj2xihfeJw9YL0YKDhvdvJ4TXs7rlPp15c3Rx1np6dG99ztapcMGgVvds+aM+pxaaUZAtNo4mT6//7OYXoMqN2CYHxX64h/MmTkRquSIE9TTp0vuDFLdBT26VejAJI3w5UPrjkeSnS6Wlw+co6ND5kvjUiSlOsW5SFUCwU6tndpqzolp2X97llnFi4J86cdVCpXCdV9USrPWqlF1Mawc7fn6IgpHm4cTXHIRSgknk6e9NYQ6MhVCPU2Jr3BWlI8/sN2HcLUTdqilUEZqZl9jXLDU4TrnzceysMVIIQNHTxqTafB8lXbRpg+u8VUQEcUoW8/DHoZIAncYpiLlOwQf3thot6xJ6ctjeAzjEM0EpC2ne5iW2N/dXwOG+JcqGhu9Ys50Ukups7xFQJBExb9f14tnlwyaTr9Vxw x-ms-exchange-antispam-messagedata: lXCz1oYALU5gKd/gpTrcVDVpAz5oUbHNvxpHH/gUsUgvEuh05zOZ+Krt0ht21fwf9xQ3b8znwCjIjfMU9YOWXnEldT2kxVNoOqkYrqCclByA/eEbij+vMQVzhcu88l9Ck6R+CHD+6J3kwMAcpQ36Lw== Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 47cd1aaa-c1da-498b-13db-08d7dc9ab537 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2020 15:28:51.7925 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: l26CHGJFLHrhDaBHKgHgOgLpQb7Xv6oBpEtSrJ6rwFUmNtMqDg2Ht3/Nj2IGr0ZCp/MbRosUB2yWCwBW6j3ZnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2423 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-09_05:2020-04-07,2020-04-09 signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There are various mechanisms that select CPUs for jobs other than regular workqueue selection. CPU isolation normally does not prevent those jobs from running on isolated CPUs. When task isolation is enabled those jobs should be limited to housekeeping CPUs. Signed-off-by: Alex Belits --- drivers/pci/pci-driver.c | 9 +++++++ lib/cpumask.c | 53 +++++++++++++++++++++++++--------------- net/core/net-sysfs.c | 9 +++++++ 3 files changed, 51 insertions(+), 20 deletions(-) -- 2.20.1 diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 0454ca0e4e3f..cb872cdd1782 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -332,6 +333,9 @@ static bool pci_physfn_is_probed(struct pci_dev *dev) static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, const struct pci_device_id *id) { +#ifdef CONFIG_TASK_ISOLATION + int hk_flags = HK_FLAG_DOMAIN | HK_FLAG_WQ; +#endif int error, node, cpu; struct drv_dev_and_id ddi = { drv, dev, id }; @@ -353,7 +357,12 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, pci_physfn_is_probed(dev)) cpu = nr_cpu_ids; else +#ifdef CONFIG_TASK_ISOLATION + cpu = cpumask_any_and(cpumask_of_node(node), + housekeeping_cpumask(hk_flags)); +#else cpu = cpumask_any_and(cpumask_of_node(node), cpu_online_mask); +#endif if (cpu < nr_cpu_ids) error = work_on_cpu(cpu, local_pci_probe, &ddi); diff --git a/lib/cpumask.c b/lib/cpumask.c index 0cb672eb107c..dcbc30a47600 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -6,6 +6,7 @@ #include #include #include +#include /** * cpumask_next - get the next cpu in a cpumask @@ -205,28 +206,40 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask) */ unsigned int cpumask_local_spread(unsigned int i, int node) { - int cpu; + const struct cpumask *mask; + int cpu, m, n; + +#ifdef CONFIG_TASK_ISOLATION + mask = housekeeping_cpumask(HK_FLAG_DOMAIN); + m = cpumask_weight(mask); +#else + mask = cpu_online_mask; + m = num_online_cpus(); +#endif /* Wrap: we always want a cpu. */ - i %= num_online_cpus(); - - if (node == NUMA_NO_NODE) { - for_each_cpu(cpu, cpu_online_mask) - if (i-- == 0) - return cpu; - } else { - /* NUMA first. */ - for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask) - if (i-- == 0) - return cpu; - - for_each_cpu(cpu, cpu_online_mask) { - /* Skip NUMA nodes, done above. */ - if (cpumask_test_cpu(cpu, cpumask_of_node(node))) - continue; - - if (i-- == 0) - return cpu; + n = i % m; + + while (m-- > 0) { + if (node == NUMA_NO_NODE) { + for_each_cpu(cpu, mask) + if (n-- == 0) + return cpu; + } else { + /* NUMA first. */ + for_each_cpu_and(cpu, cpumask_of_node(node), mask) + if (n-- == 0) + return cpu; + + for_each_cpu(cpu, mask) { + /* Skip NUMA nodes, done above. */ + if (cpumask_test_cpu(cpu, + cpumask_of_node(node))) + continue; + + if (n-- == 0) + return cpu; + } } } BUG(); diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 4c826b8bf9b1..253758f102d9 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -725,6 +726,14 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, return err; } +#ifdef CONFIG_TASK_ISOLATION + cpumask_and(mask, mask, housekeeping_cpumask(HK_FLAG_DOMAIN)); + if (cpumask_weight(mask) == 0) { + free_cpumask_var(mask); + return -EINVAL; + } +#endif + map = kzalloc(max_t(unsigned int, RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES), GFP_KERNEL);