From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A876AC433FE for ; Tue, 31 May 2022 17:31:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 270F76B0072; Tue, 31 May 2022 13:31:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 223AD6B0073; Tue, 31 May 2022 13:31:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 111B26B0074; Tue, 31 May 2022 13:31:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 049A36B0072 for ; Tue, 31 May 2022 13:31:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CA318607B6 for ; Tue, 31 May 2022 17:31:56 +0000 (UTC) X-FDA: 79526731032.03.A3851E5 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id 5DF9B1A004F for ; Tue, 31 May 2022 17:31:41 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id CAA03B810F1; Tue, 31 May 2022 17:31:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B8A9C385A9; Tue, 31 May 2022 17:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1654018313; bh=cM0mLgtDwe39r85Qpbwx1gsGZl9Em45suJNmKfe2840=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OKOg1WE09YZpMfWsIy3ozjQL4j7YRHDfSWT7tpHSI4MbkjXTm/nxPhAOzaTq9nu6L 5oThGX/yQh5E/+oczf87CwQhJN1ZPq0rn6/MKsFTFqhWxZK+SEJH5R4IF5DyWaK4+e 5hdkzB4zjrPJroW1rabz6XKjJaQAMgDQaW1OYYD4= Date: Tue, 31 May 2022 10:31:52 -0700 From: Andrew Morton To: Alex Sierra Cc: , , , , , , , , , , , , Subject: Re: [PATCH v4 07/13] lib: test_hmm add ioctl to get zone device type Message-Id: <20220531103152.6b9214cc39a87020d7d7927b@linux-foundation.org> In-Reply-To: <20220531155629.20057-8-alex.sierra@amd.com> References: <20220531155629.20057-1-alex.sierra@amd.com> <20220531155629.20057-8-alex.sierra@amd.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=OKOg1WE0; dmarc=none; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5DF9B1A004F X-Stat-Signature: rsanii3p3apk1of5x6uksk6g9do3jb4o X-HE-Tag: 1654018301-868774 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 31 May 2022 10:56:23 -0500 Alex Sierra wrote: > new ioctl cmd added to query zone device type. This will be > used once the test_hmm adds zone device coherent type. > > @@ -1026,6 +1027,15 @@ static int dmirror_snapshot(struct dmirror *dmirror, > return ret; > } > > +static int dmirror_get_device_type(struct dmirror *dmirror, > + struct hmm_dmirror_cmd *cmd) > +{ > + mutex_lock(&dmirror->mutex); > + cmd->zone_device_type = dmirror->mdevice->zone_device_type; > + mutex_unlock(&dmirror->mutex); What does the locking here do? Presumably cmd->zone_device_type can become out of date the instant the mutex is released, so what was the point in taking the mutex? And does it make sense to return potentially out-of-date info to userspace? Perhaps this interface simply shouldn't exist?