Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp739034ybl; Tue, 13 Aug 2019 01:43:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFaekHqGW3RL/kDVesYVhl0GpUoEAdjtE8HO3pU0g3ZopnDKu8v5T78C21Y1od3ueW2Ru6 X-Received: by 2002:a17:902:be03:: with SMTP id r3mr37250342pls.156.1565685800981; Tue, 13 Aug 2019 01:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565685800; cv=none; d=google.com; s=arc-20160816; b=fjh9VEPw8xkW8+qc08a/DUjpDrp6CUih2AQ/9/7v+/EoqDXrnSgmBuKkVuxapWg6Bf BIUDIxJIm5MkPZ6Viy52YNhqYclxBl1vhf/gsJnqw2iMSCYjfy5BCi7c7bDnzbJJBaGJ qHvCTE/JgXx0dsurLHbFHUtDQ9i0qPZT0g03ByD5f4Fo26uUWKHAcxRjCHJTFyk9A6VT IxyBV83Zf8+OcnJJEihZGPf9Wse/dclCihKEXiFlSC12zT2RoH8mvionw0dmhSdG9TQi fd5CVkCyqL3vRrgih6opWIUBb9MzbPkCXPWB0y4s5ODugPSxsdtWv3xrbDnP4dMnLpA5 EGPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nDqwpC1PppEk839MgFZPsscd9ykxNNHqiMTtehSc/zo=; b=KEfGVeJ7yeFvsE1U6sA/ESLICG8YrAHh7aMjcGuYAXE8hNCl9vdF23VxGtwpbcwJu/ fErHMi3WE4cNZDrf7Bk6zoez2her8DH7K3sjBrsZc74Xl0038izUZF59eLk+D7ocflgn sgiM4ScvU0PWtmz+mldVrQVjHwl++XzAW8L6b/gDYrLAyveLAu624BAjWxSgV/Jywg4u mKjo6t7aKx86k/qXq75ILyYxWOXfRU2Cu3cjU8F1SSAlZ/0vpX1ZnwcIgiYh2JEBKauZ v/6e2mWZNTtlVcGkZ8NS4XJTn79wRHxWjNG7mKR1I/ikUH2bfoc164Hx7x1bRdLC7iMt fBfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fe5iapZq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e20si34628554pgn.181.2019.08.13.01.43.05; Tue, 13 Aug 2019 01:43:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fe5iapZq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbfHMGKh (ORCPT + 99 others); Tue, 13 Aug 2019 02:10:37 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:36115 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbfHMGKh (ORCPT ); Tue, 13 Aug 2019 02:10:37 -0400 Received: by mail-ed1-f67.google.com with SMTP id p28so356116edi.3; Mon, 12 Aug 2019 23:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=nDqwpC1PppEk839MgFZPsscd9ykxNNHqiMTtehSc/zo=; b=Fe5iapZq7OOYHH5az8a2OmwaeUZo7LYmEH/pXBcrEYRZLstiljVxGNHow5U4z5RIh8 RJDBweOkt4NWgKKYdysVug58aW7GzWS4TJHTsr/o8F5Wnz4EEtHs9wv5MphGnEHY7mMR vKeD0pwuU6ri0O2sMuZDAtkLLv+KV0VeKRReP65rVMvLxtzrKS3TajypcHyVRsE0ysXT EXJ1QHOMF+XF17gAHIyHOK4Z/T4jVHQM/mWjB8BdEHca0uCS6mrYJr7CdK5rn9JAluyX lefiA/s1W1YxedERV4XyQv5wmtwOtKYn//hlCE6T6kd0H25v+BNJ+EOE8a5FLVP02kPx 8VEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=nDqwpC1PppEk839MgFZPsscd9ykxNNHqiMTtehSc/zo=; b=RZYD0AfJFDWeH5ZpNPW8l7iaQXRPWyM7YZ1CAVz8m2NuQeM4eXlmv1dPr6bY6vNsL6 4S4CRmgG0hPfpR61BEcvMnQ4l8hIEFawAzdWOltLVGAnK8uIcvHSJdCwLpxHb4EAnd6q fEhW8LhqmQn8cP7VuVE4yfnIxUYkn8SytuiQa4p5VvMQC9r7mukwYmaXMQ0qnwkPoKA1 gVE5HJA1C8jELnMk3HreY2DhzGdmwWN9Qj1P+4crH+vBJRNLdiLeu8SMV3/Xiw7Sg4JN 5ii+qOkVFb4imkErjX7AhUz0W0TPIXdceZl0Ri+RAM9+uOSxX/EjwPEZSpRZURZWJJCd StGw== X-Gm-Message-State: APjAAAUiwp5VGqy6U10nV977zGoBOHF5YRwEYV6vDx1E8Vm8nD9EKv5P b9jwwefjskhJbY2iG8kxVF9AFMyLmoI1aS/luyA= X-Received: by 2002:aa7:d781:: with SMTP id s1mr40421978edq.20.1565676635498; Mon, 12 Aug 2019 23:10:35 -0700 (PDT) MIME-Version: 1.0 References: <20190808131100.24751-1-hslester96@gmail.com> <20190808133510.tre6twn764pv3e7m@Air-de-Roger> In-Reply-To: <20190808133510.tre6twn764pv3e7m@Air-de-Roger> From: Chuhong Yuan Date: Tue, 13 Aug 2019 14:10:24 +0800 Message-ID: Subject: Re: [PATCH 3/3] xen/blkback: Use refcount_t for refcount To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: Konrad Rzeszutek Wilk , Jens Axboe , xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 8, 2019 at 9:35 PM Roger Pau Monn=C3=A9 = wrote: > > On Thu, Aug 08, 2019 at 09:11:00PM +0800, Chuhong Yuan wrote: > > Reference counters are preferred to use refcount_t instead of > > atomic_t. > > This is because the implementation of refcount_t can prevent > > overflows and detect possible use-after-free. > > So convert atomic_t ref counters to refcount_t. > > Thanks! > > I think there are more reference counters in blkback than > the one you fixed. There's also an inflight field in xen_blkif_ring, > and a pendcnt in pending_req which look like possible candidates to > switch to use refcount_t, have you looked into switching those two > also? > It seems that xen_blkif_ring::inflight is 0-based and cannot be directly converted to refcount_t. This is because the implementation of refcount_t will warn on increasing a 0 ref count. Therefore I only convert pending_req::pendcnt in v2. > Roger.