From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753530AbdLHVVh (ORCPT ); Fri, 8 Dec 2017 16:21:37 -0500 Received: from mga07.intel.com ([134.134.136.100]:13121 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752530AbdLHVVg (ORCPT ); Fri, 8 Dec 2017 16:21:36 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,379,1508828400"; d="scan'208";a="185003583" Date: Fri, 8 Dec 2017 13:22:48 -0800 From: Jacob Pan To: Alex Williamson Cc: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , Greg Kroah-Hartman , Rafael Wysocki , "Liu, Yi L" , Lan Tianyu , "Tian, Kevin" , Raj Ashok , Jean Delvare , "Christoph Hellwig" , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v3 10/16] iommu: introduce device fault report API Message-ID: <20171208132248.60bd65e7@jacob-builder> In-Reply-To: <20171208135909.0ee02d16@t450s.home> References: <1510944914-54430-1-git-send-email-jacob.jun.pan@linux.intel.com> <1510944914-54430-11-git-send-email-jacob.jun.pan@linux.intel.com> <20171207142725.731695ea@t450s.home> <20171208122358.720edd9d@jacob-builder> <20171208135909.0ee02d16@t450s.home> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 8 Dec 2017 13:59:09 -0700 Alex Williamson wrote: > > > > > > Isn't this all rather racy? I see that we can have multiple > > > callers to register racing. > > I agree, should use a lock here to prevent unregister. For multiple > > caller race, it won't happen since there is only one caller can > > register handler. > > If you have multiple simultaneous callers to > iommu_register_device_fault_handler, they can all get past the test > for fault_param (testing and setting is not atomic), then it's > indeterminate which handler gets installed. Thanks, > I see, having the mutex would prevent it. Later callers would get -EBUSY. Thanks a lot! > Alex