Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1015634rwi; Wed, 19 Oct 2022 05:52:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM65tK49LtTbTV3yN9Tump3sEPHPK/dLc4ecS1UYGHazeGCv14YlKcs2uvih4aEFYovB6bIU X-Received: by 2002:a17:906:5a6a:b0:78d:d25e:55de with SMTP id my42-20020a1709065a6a00b0078dd25e55demr6463645ejc.130.1666183944435; Wed, 19 Oct 2022 05:52:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666183944; cv=pass; d=google.com; s=arc-20160816; b=mam8KrJpOwYugpXp2MFXaW6iWovxqo5UuCQ3DM2+j0tTQzp7LyB3oJjyy0mR+GUC8k s7HdbpDeMfT7FLgNX3lCNMP78wBF69+4JO5q6UTuXSlvBWYPXQAk7+AP1QsDfWKSF5gS GUieRFDvTpwreElmIQw+HFskIxFdv7Uc/lo7TGOg1UVRiCZf8pewk1J4A1y6VvuVBDmL tYk5JX6a1G7SV1z400wt9G9onhsr7ssPiMludvPYW45f18HCA51W9C+Ao0ksktf+3PDp l4GI/RpTzbJH7ZHRXPK4VxqVl8CnkmHcMhHtkxL0wzifsYGC8xNmy3cZz9SWYz9tMAuA CIdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SAIkjoKxC3pIOdcBlF9pfDE6MXcc9DZZ7LqpjGGjYnE=; b=WeHpc4G046p5I/9i0eTfF7ncV6llyVkQpWNyRsNp1qohsqio1loJGfOK1Kw3T5LzgR acWVaiF6QJMUDiKb2XHR5iOsCHOfMPIJab94tM8Yxls3WAlAhr9Icdu4c2SPJtAOBo3V xlIAXhid8HX2bBLCIXNwo+l1vwYTetyoAbh/30aYfXayUNsyd7hUgJNZ6gQ2Y1Euer39 uPZjk9TB0JDQVi643hUHcHbExU4tBv+f/41IPAO3q7/Lyg5UGi908uvZJc9LopYUuLL8 CwKFufhdsYcsFNnNZjmG0cwi2pwLTGbAgyZOEApSshmAZCZOILgZTDEHxDVQj3FX0/TQ 1qAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=P8CWsR5j; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a1709064d4e00b0078dc7dab177si12357445ejv.311.2022.10.19.05.51.58; Wed, 19 Oct 2022 05:52:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=P8CWsR5j; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230217AbiJSMUi (ORCPT + 99 others); Wed, 19 Oct 2022 08:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233001AbiJSMTW (ORCPT ); Wed, 19 Oct 2022 08:19:22 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79BFF2D758; Wed, 19 Oct 2022 04:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WoT6ZMYXf3ZRgE/dc4i5oQ+tZUE7v5EU0XcrPPRhUD2CihthYDnBSRfwdHKeYQTDG/9IuIU7scKqgIR+s7Jz7slyLP39M02+zbxgQYCx8Wg8FFZCXHRfoOruQcIfZHIJ6/71aLwXmw8EPSMJY6MZGJF9cabjMtTYlDm5UYg5PLleTc05xgJmdKba5F396sBTy9I8SQ7s4XZ5Q3IzWAp1o2e48C4MoQzbnzR8XVo0z/IEnMD0G6H3wzFM/Fe3S/OGJXaOBToOqgR9dHGjrpdqmrp3Sg6oMI4G4zT63B8f2YAWT4M/o8yzaLOXGy35ryl+wzlVFr17Am1h6SS7Zvbncg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SAIkjoKxC3pIOdcBlF9pfDE6MXcc9DZZ7LqpjGGjYnE=; b=FIwOdfUGTmdzvz6Y43C71vPBM96tN5aeeUCfyV+Kng4W+y3KY3SRIoEURDk3gBYDT8Z0fF3nH2sRj6kvHwrHHw2dMzqV/pG2kfQb6rTJuHPKJ96i2pJwbmZVcuQCwd10HPZ9d8HxRf652DCG1DcJm4RgcgUgMB/4EJmjvtMBunkjCOSNRAU7S2s3Ryw2vV4/YSTEKfCLv1wyc2udHD3zG0nrXoRk9LYq00iPEg4SHrdxqSjfD1h4P22+mMzVc1iSp5j085x3AZ1Y7SVU1h+LxOphL0LZEdapdER7jCmjYTK6fucvZBQiUcOXk6nByjnPtQEQqEQ1mb5m2ZsX1I5QrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SAIkjoKxC3pIOdcBlF9pfDE6MXcc9DZZ7LqpjGGjYnE=; b=P8CWsR5jIRgwpKAduJWiA7bxZhnQfAbxDH0rhC7kXnRnvZG1ELImYPnhyT248aTdb2rlr5nGOnteYPD9ax0gKUhtWci+B3m0/9AMs3KDiK3uYZjRUdV30DUvgGt3aGuB8YsahCO6JeM7kfDWKEKa74wTKQZrTgkTO89o0NXHBxtVsiyTC+bDYvMFOSq/JZU0vb8O179nKAM7sz1fsvkYc7Zcgbunh6V3HeizT2C+9QPstR3aw5m1558xhBEeEb3Xgywskbxqow2Y1N4TyAulyjlQze9YF6K9TT1koguf6nlZtOgWQ4l3zJg34K27j//XotcDq2F0e/AZLN8TSOPi5A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by PH7PR12MB7307.namprd12.prod.outlook.com (2603:10b6:510:20b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Wed, 19 Oct 2022 11:53:22 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::7a81:a4e4:bb9c:d1de]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::7a81:a4e4:bb9c:d1de%6]) with mapi id 15.20.5723.033; Wed, 19 Oct 2022 11:53:22 +0000 Date: Wed, 19 Oct 2022 08:53:20 -0300 From: Jason Gunthorpe To: Niklas Schnelle Cc: Matthew Rosato , iommu@lists.linux.dev, Joerg Roedel , Will Deacon , Robin Murphy , Gerd Bayer , Pierre Morel , linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] iommu/s390: Use RCU to allow concurrent domain_list iteration Message-ID: References: <20221018145132.998866-1-schnelle@linux.ibm.com> <20221018145132.998866-4-schnelle@linux.ibm.com> <8e268ab5e0dadf86be5fd7ffaa9debb76cea67f3.camel@linux.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8e268ab5e0dadf86be5fd7ffaa9debb76cea67f3.camel@linux.ibm.com> X-ClientProxiedBy: BL1PR13CA0433.namprd13.prod.outlook.com (2603:10b6:208:2c3::18) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH7PR12MB7307:EE_ X-MS-Office365-Filtering-Correlation-Id: 4077c7ec-a773-41d1-cacd-08dab1c8857e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6k5EotypyWymwBB42MEVvltT87grqPDUCU9ohgIOou8iEt33qGFb86+hE9Xe7Ua7P8x5bRlh5NgVW5c604jRtHux34N6aGVP2mISk++H9mJPhiPIy579b2yocrPdf3xX8gnbQzE/C2EcupNxfQ0YfIojyOn/Sh7oVEJlS++TrW0x1xMQiDOjdkgWGW9RBxEqczsSCtK9gdLhrICyV1AnjhOlkVk1NU4amCa8PtoEaA4hshjUrNTD9geb7jtLYIKXaQJxvtOlTKALnJwzmVoldz0JkGzMKk98UihVPxkACpshs6KD36ZqZ6ShLl9T69FnDNd2qM19QMvhQke3thcx64YScVQqlddAqYvWrCGNOVq1nNt69ImAgG8fTlalbwYKnMX3P4jL5laMtwuU/JfAk2y9QW6/WDn+/eH8W0gb4K6Fy/V/yZnCPVWzThfZAfD5KuS5QPHbpFPFjYWaRt/PGUWhuCVww2Y4JVRSaCRyZTFi11TeiSeKeHbl7tmY6ssx0A731UTof5TtEbileGfGUuW4SAlxyUz+r/Rf2dOkubIOnS0UbFhOce83ia9M92M7p2Diw8ZN3H3lHyNiVSxNIjMUoFhD3POSQ4Fvow/D820qmjil+EquIgmtcA12nUZ6sMaqM8GUqRfYrnFtxWjUBtb57PA4TVtfi5qInvOSn7zOIRTvFVOovTNNW8frSC6CCgx7vkJEFK7ICv1eGaYzug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(39860400002)(346002)(396003)(136003)(376002)(451199015)(38100700002)(86362001)(41300700001)(6506007)(316002)(6512007)(6916009)(26005)(54906003)(5660300002)(8936002)(4326008)(6486002)(478600001)(7416002)(36756003)(66946007)(66476007)(8676002)(83380400001)(66556008)(4001150100001)(186003)(2906002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ZgqiUD5hM+Axckl6sQ2yBizFLCEzXXNEVcMjgaTyYCn7zICWNsBppoxg3G1Z?= =?us-ascii?Q?XYdc8Rh/wGSi9HFKPq1tagGmtRNPHWfQ0i0krKu2ok5UHRPpwJKuEyo/WBUa?= =?us-ascii?Q?wh4xdPX/Th64gMjP1CTvx3pIbhsufZLiaSv4a4nxRLkyPqdnd7w3GLo6unG0?= =?us-ascii?Q?WYyHzHDYQU+5liKHY4nIhFk2aTmCPz3/ngikRg2fd/OBZtCqIQNlc6Le86gd?= =?us-ascii?Q?jGXvIwS2Np27acFFitxC6TSXY1mU24zk7IN4E5JCcfYwsQq3cHVmRodqtqrR?= =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g7j+o0lunfoRhUPwLS0yD2Aj54d28Vhagh?= =?us-ascii?Q?MGENjfkIDPCvozGMUQbj4wVTFcohFrGkXMXa7CenQQ91LXMyGrtUWiqN59Eu?= =?us-ascii?Q?Ib8AXTyer+w3aoWz8o5faovnuoctkpQT8wvFAcikNf6tJpqrshixy7uL52aM?= =?us-ascii?Q?xBjeWaRFbNFk1Iyzguacmw+BgzQYaqyrV6pTPEBiEBn8LvBZujzopN7waBtu?= =?us-ascii?Q?k35ysnqbQxK8MZXnar87sv4CK3aCW6EGMpJ5Na16Z5jUFVxKJVOEKOIupmZC?= =?us-ascii?Q?Ax47xcwEB196WbFvsmlRT6V2Jm6AHZXyXimQ7ULsJNwOhAnVK8pfzJDrpuaI?= =?us-ascii?Q?jmnFlEiysDIelc6PZnlqF0OoOzWLUeCgP4xZgTdpTarDzQJGvnN52cD3OFZB?= =?us-ascii?Q?VbnmVOmWyc6PbNLmM1U=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4077c7ec-a773-41d1-cacd-08dab1c8857e X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 11:53:21.9632 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6lPcJ1aETTxaQo4UnF+9Kjbv+JEE2/LWmml/+gy3x9QKMD++6brib8kK0ymsFnEP X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7307 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 19, 2022 at 10:31:21AM +0200, Niklas Schnelle wrote: > On Tue, 2022-10-18 at 12:18 -0300, Jason Gunthorpe wrote: > > On Tue, Oct 18, 2022 at 04:51:30PM +0200, Niklas Schnelle wrote: > > > > > @@ -84,7 +88,7 @@ static void __s390_iommu_detach_device(struct zpci_dev *zdev) > > > return; > > > > > > spin_lock_irqsave(&s390_domain->list_lock, flags); > > > - list_del_init(&zdev->iommu_list); > > > + list_del_rcu(&zdev->iommu_list); > > > spin_unlock_irqrestore(&s390_domain->list_lock, flags); > > > > This doesn't seem obviously OK, the next steps remove the translation > > while we can still have concurrent RCU protected flushes going on. > > > > Is it OK to call the flushes when after the zpci_dma_exit_device()/etc? > > > > Jason > > Interesting point. So for the flushes themselves this should be fine, > once the zpci_unregister_ioat() is executed all subsequent and ongoing > IOTLB flushes should return an error code without further adverse > effects. Though I think we do still have an issue in the IOTLB ops for > this case as that error would skip the IOTLB flushes of other attached > devices. That sounds bad > The bigger question and that seems independent from RCU is how/if > detach is supposed to work if there are still DMAs ongoing. Once we do > the zpci_unregister_ioat() any DMA request coming from the PCI device > will be blocked and will lead to the PCI device being isolated (put > into an error state) for attempting an invalid DMA. So I had expected > that calls of detach/attach would happen without expected ongoing DMAs > and thus IOTLB flushes? "ongoing DMA" from this device shouuld be stopped, it doesn't mean that the other devices attached to the same domain are not also still operating and also still having flushes. So now that it is RCU a flush triggered by a different device will continue to see this now disabled device and try to flush it until the grace period. Jason