Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp724824rwi; Thu, 27 Oct 2022 06:58:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Y9H4AbYueWQCC1uRdUdj65k7gZDEEFdVAUF3r/dPYHWXFjOPtgSCEL99ZzUeo/D+dJypq X-Received: by 2002:a17:907:75ed:b0:78d:97ed:2894 with SMTP id jz13-20020a17090775ed00b0078d97ed2894mr40998031ejc.739.1666879087863; Thu, 27 Oct 2022 06:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666879087; cv=none; d=google.com; s=arc-20160816; b=txagX3VRow/9e79thExwbIjkmXx7TIOgxvmz9UmWAOsUyAzj1cRUiKtOI46K2NddCq DVPmkWMmSfeQlKyY/6ZFYyQsQ+52+dPoabnnSZo6a9ZPfYWCNfCJY8tolZnar/V6mLJk evIkf/knMMvGvwnzjTkf0VRiwZQn3ENw+437tS3RK+G0Ao43I/AmN5aJovsloIXdsNMq WV7kzXIdlHd2EKI/nmRyegHPgF+xiVHPcgAr06OyVQfebPfYTmsSXlHlLg5OhPYv2nWI xxiNoNhBYfXAhnT1Ke/hJMmpJTT9Q/AMTYs52khbqSCYZGUDGPTvjulludtMiW7v460i yB4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=Ejl5T5rkkQKY1oA+EH7MPZdTTOrGhLrVrHhBB8NLPaA=; b=qMlEKgqwmu2lLSn6vDlwukOpy5fwI/lvmexTQg+zQyDBDcvKb93icSo42OdEIf5F1J S6tk3XYLJ4Yw+7BGk6b1AjXHfNIN2D5FC8NXmQqwyjGdMmRVI3kCNh6qMjQp17rGjAIU r42OnhRc77X2vt4HHxSuF2LeXsCE7GrjJgPqjMS5+pZBumTHYtu2r8C7Els8EkQ8SGYi +vi8Efu+HWBtPmBV4zj/1yEcYXxgID5qCTPra9AUbRh2H4OTGdCjAQ8rYp1Xt34Qk8Q2 GaZlJiLN/3SiPJm3zv3Sb7cw2IrIAC5f8/30JFMwC4vLNe9PONbDr+ep4K6zDZdWOp5E Mc1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=PglINzJX; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a170906644b00b0078d805901b1si1118498ejn.489.2022.10.27.06.57.42; Thu, 27 Oct 2022 06:58:07 -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=@ibm.com header.s=pp1 header.b=PglINzJX; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236225AbiJ0NiC (ORCPT + 99 others); Thu, 27 Oct 2022 09:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236203AbiJ0Nhu (ORCPT ); Thu, 27 Oct 2022 09:37:50 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E6161814A6; Thu, 27 Oct 2022 06:37:49 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29RDKUSF027366; Thu, 27 Oct 2022 13:37:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=Ejl5T5rkkQKY1oA+EH7MPZdTTOrGhLrVrHhBB8NLPaA=; b=PglINzJXYiVe4F0ZW5eltGBfoTy1FGILlDJT/TPmADIpuFVzFG9ory5HMOoQG4G+lflc J03o+a2kpPaZ8vmdVokQTiVepwiUU8efaorgPUSHJkFuekCiaLXJFfAh4m3v65er1x7m uiwTvURLb8LRpkqVdmeMfK+xST4jgxrc3cqWG0F6jfU4zp/3jxST60KysftUHjrsc1SD RufzTTiCAx1EM9NcbPz/TBqjuxzx2iTLR7jUzN6GrlwvGHpJmm6PtbM5kjKqpgz8ULad xdR5cxJ+gpaDSxTWo7G2LPzl3L/q6xOyb7VzYFefogUtE3KwpoBUsbHNmUzOhFOAnukx 3A== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kftspgj1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Oct 2022 13:37:33 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29RDKJAa015026; Thu, 27 Oct 2022 13:36:01 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3kfahd1dcw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Oct 2022 13:36:01 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29RDZwEV64094482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Oct 2022 13:35:58 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18F0E11C04A; Thu, 27 Oct 2022 13:35:58 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E06911C050; Thu, 27 Oct 2022 13:35:57 +0000 (GMT) Received: from oc-nschnelle.boeblingen.de.ibm.com (unknown [9.155.199.46]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 27 Oct 2022 13:35:57 +0000 (GMT) Message-ID: Subject: Re: [PATCH 3/5] iommu/s390: Use RCU to allow concurrent domain_list iteration From: Niklas Schnelle To: Jason Gunthorpe 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 Date: Thu, 27 Oct 2022 15:35:57 +0200 In-Reply-To: References: <68d91d7a5aadbd46dc34470eccd6b86a84c9e47b.camel@linux.ibm.com> <89a748fb5caee8be5d91806aa5dfd131e92d5d82.camel@linux.ibm.com> <3c2249fc7abf481b15d4988c2bd6456c48154c44.camel@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4UEH8TwDmXoB9rlck4hFIklWCJOZ7Bvu X-Proofpoint-GUID: 4UEH8TwDmXoB9rlck4hFIklWCJOZ7Bvu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-27_07,2022-10-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 mlxscore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2210270073 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Thu, 2022-10-27 at 09:56 -0300, Jason Gunthorpe wrote: > On Thu, Oct 27, 2022 at 02:44:49PM +0200, Niklas Schnelle wrote: > > On Mon, 2022-10-24 at 13:26 -0300, Jason Gunthorpe wrote: > > > On Mon, Oct 24, 2022 at 05:22:24PM +0200, Niklas Schnelle wrote: > > > > > > > Thanks for the explanation, still would like to grok this a bit more if > > > > you don't mind. If I do read things correctly synchronize_rcu() should > > > > run in the conext of the VFIO ioctl in this case and shouldn't block > > > > anything else in the kernel, correct? At least that's how I understand > > > > the synchronize_rcu() comments and the fact that e.g. > > > > net/vmw_vsock/virtio_transport.c:virtio_vsock_remove() also does a > > > > synchronize_rcu() and can be triggered from user-space too. > > > > > > Yes, but I wouldn't look in the kernel to understand if things are OK > > > > > > > So we're > > > > more worried about user-space getting slowed down rather than a Denial- > > > > of-Service against other kernel tasks. > > > > > > Yes, functionally it is OK, but for something like vfio with vIOMMU > > > you could be looking at several domains that have to be detached > > > sequentially and with grace periods > 1s you can reach multiple > > > seconds to complete something like a close() system call. Generally it > > > should be weighed carefully > > > > > > Jason > > > > Thanks for the detailed explanation. Then let's not put a > > synchronize_rcu() in detach, as I said as long as the I/O translation > > tables are there an IOTLB flush after zpci_unregister_ioat() should > > result in an ignorable error. That said, I think if we don't have the > > synchronize_rcu() in detach we need it in s390_domain_free() before > > freeing the I/O translation tables. > > Yes, it would be appropriate to free those using one of the rcu > free'rs, (eg kfree_rcu) not synchronize_rcu() > > Jason They are allocated via kmem_cache_alloc() from caches shared by all IOMMU's so can't use kfree_rcu() directly. Also we're only freeing the entire I/O translation table of one IOMMU at once after it is not used anymore. Before that it is only grown. So I think synchronize_rcu() is the obvious and simple choice since we only need one grace period.