Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp462664pxb; Wed, 13 Apr 2022 05:59:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxseyn8sXO6uHMuvhH33iyG2xFNRuNw4mjAv14JEACaLtVV6+jvG94tWDLjQnOk8dt9adpA X-Received: by 2002:a17:90b:789:b0:1bc:293c:1445 with SMTP id l9-20020a17090b078900b001bc293c1445mr10543971pjz.111.1649854780647; Wed, 13 Apr 2022 05:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649854780; cv=none; d=google.com; s=arc-20160816; b=ficsLWly6R4lvsg31kViqODY3Z9ei6AOkEGNcw9YysGXcr4/hg5dvF8ge8ZzZit71c 9QmYAhCZm70GcLsb9J4osKKURusQp+P6B91zeQU8OxqBYn7l4WUpVjla4Wz3U8qcJ30B TOi3sJ4iwROInZKTEsqz27HJnEW2Zu1lsl08+zEVDyiDi0KPHn73wLwPfNXdejP/0HK3 kAwmcxSn5dtTVFWOfO4G9aKwBDHUqrORDh8/ZX8k7of9FyIvRhyMiv/pcih+7D2WmJlG CVt4hyaQ9BeF0UJIerch3J9j3MJQAxayr6uX47vSVeUeoUt9V3Q9TSnwrc5dV2V8CUGI /YZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gEuQC480KR9IHjfkNkqN24vp9ZMdulfpFV/WkVub7hI=; b=rpsz5CDoea5QIALYm75pUAqww7oeTHIbQxoP4HQ3Qr2ZpBK5i4gR5gz0gIBLsi90ld GQZZTmW8KsIrIq+8rAB16k1599SESXMEX1YFMNZq4f9UN7gtkueYHoqwwim/9HXacsHq Kh7kjpfPpUE/rmqriRV7uCs26Uvvtkg5I9RlgBWIRCRIDh7anggJqCGeGBA2aDvaTTnI 2GZZz2zzF70jwx/2mx1usJHxE2o2nGBlUWP6c5rC8U43LNl+z6Qt2NkTpDGZKmQN3Df0 g6wXh1K4RHA/1RUY/Su8sJPWadLt50KIULVmEaEjIn559Y1/25hN1ErGMwK/i+IhwUN6 ZqEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kFcJDmu6; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n2-20020a63b442000000b0039da5aa4ed6si3762674pgu.710.2022.04.13.05.59.26; Wed, 13 Apr 2022 05:59:40 -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=@linuxfoundation.org header.s=korg header.b=kFcJDmu6; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234702AbiDMJqP (ORCPT + 99 others); Wed, 13 Apr 2022 05:46:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234673AbiDMJqH (ORCPT ); Wed, 13 Apr 2022 05:46:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C2F256208; Wed, 13 Apr 2022 02:43:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9BB9361AB6; Wed, 13 Apr 2022 09:43:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA242C385A3; Wed, 13 Apr 2022 09:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649843026; bh=jcmwPp4MF6Yr0BKX1cHrkpKFTpSsXujiXAGpaOJWw/8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kFcJDmu6gGoU9P2nAzY/jutQqkM4Yx5pozWwXcjBIYo6yGGPOW5oi5S44hagvG2XJ a95mgxZ+s9t+e1xQl2Tgbo7dGuGkLnU+nDbcTy/6jDlxBubD0/rdJtovw8yTrjqgA3 eHCJXfI7jhQJk9+VHlF/ksmm15D3JuZt5WuHZR78= Date: Wed, 13 Apr 2022 11:43:43 +0200 From: Greg KH To: Yao Hongbo Cc: "Michael S. Tsirkin" , alikernel-developer@linux.alibaba.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] uio/uio_pci_generic: Introduce refcnt on open/release Message-ID: References: <1649833302-27299-1-git-send-email-yaohongbo@linux.alibaba.com> <20220413044246-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Wed, Apr 13, 2022 at 05:25:40PM +0800, Yao Hongbo wrote: > > 在 2022/4/13 下午4:51, Michael S. Tsirkin 写道: > > On Wed, Apr 13, 2022 at 09:33:17AM +0200, Greg KH wrote: > > > On Wed, Apr 13, 2022 at 03:01:42PM +0800, Yao Hongbo wrote: > > > > If two userspace programs both open the PCI UIO fd, when one > > > > of the program exits uncleanly, the other will cause IO hang > > > > due to bus-mastering disabled. > > > > > > > > It's a common usage for spdk/dpdk to use UIO. So, introduce refcnt > > > > to avoid such problems. > > > Why do you have multiple userspace programs opening the same device? > > > Shouldn't they coordinate? > > Or to restate, I think the question is, why not open the device > > once and pass the FD around? > > Hmm, it will have the same result, no matter  whether opening the same > device or pass the FD around. How? You only open once, and close once. Where is the multiple closes? > Our expectation is that even if the primary process exits abnormally,  the > second process can still send > > or receive data. Then use the same file descriptor. > The impact of disabling pci bus-master is relatively large, and we should > make some restrictions on > this behavior. Why? UIO is "you better really really know what you are doing to use this interface", right? Just duplicate the fd and pass it around if you must have multiple accesses to the same device. And again, this will be a functional change. How can you handle your userspace on older kernels if you make this change? thanks, greg k-h