Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1991987pxk; Mon, 14 Sep 2020 01:33:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSQPknsTMfzWZqHCgsXW9tCkKIdBFNMldTli02sA9vAYRC2ozbI6bFbGZhoipvfN7tLyJE X-Received: by 2002:a17:906:a88a:: with SMTP id ha10mr14418640ejb.532.1600072410610; Mon, 14 Sep 2020 01:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600072410; cv=none; d=google.com; s=arc-20160816; b=xWu2OvBhUaBTAds6X6MKDTmp1yy8C4+n8vD9NFWsZhqBvdnT2SHV2N7g1vu45m7a89 5D2FPq38+hmwSmQdzE2LHBzYxCt4K23GB8hCCghHDgrtzZVQq8DFfWVuRvwNPvA+rxt+ iRlnPqH1skIkb8lnLmG+RuT/ik3FNmOGMzeBdt/vbFEbUl2I5H1ekm3gtx5lGnfnPSac aiDKjcexfuRYdX8NY5tH5s7vSA7cbF7pbniBfUBYN8oo2BY29VzF/qySm/OFKWhm5Wk5 OSakeIrEtoNP8RFyRG41gInvFwEAmgaawVnbyM3mUOVneFeV0OWzcEfCSZLzD/VVWfor MoAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date; bh=slhrZCKrdO4mAuUHqBFgn9Y9HHsE+QNov3f8GqgmZN8=; b=ySQXKUfiZ/Uhhb2skdMSihaEws7+4NLunXmfbPdYdD9bL5E5wkdcXejGq0FFOgp138 CFkEQs0x7RwJkXF+LcT1EgCOhys6kvJQSrY0tPe447M+JhOlsEv73U3Xapjl9EbqYFh4 QrBzhACVDtlfzL6Tftcgw9Rell9oSfXV5IhWwnGH4cCEvAerVQItMFzZO73gO9m6RLHO oueAORNvVWAafWZrl9ZUdafgJqwl4VsxMCWEuZnUQFmFR160uHVaDdttfGF0WB5K17/v 0WBfVV212EFkRZCkpUVFhykqDVfQ0bTjmnFe3q4yPm1JYutZw3n+2cvgL0MKoSl4OsER qq3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si7281519edn.316.2020.09.14.01.33.07; Mon, 14 Sep 2020 01:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726241AbgINIcU (ORCPT + 99 others); Mon, 14 Sep 2020 04:32:20 -0400 Received: from nautica.notk.org ([91.121.71.147]:42460 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgINIcT (ORCPT ); Mon, 14 Sep 2020 04:32:19 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 77BEFC009; Mon, 14 Sep 2020 10:32:15 +0200 (CEST) Date: Mon, 14 Sep 2020 10:32:00 +0200 From: Dominique Martinet To: Jianyong Wu Cc: "ericvh@gmail.com" , "lucho@ionkov.net" , "v9fs-developer@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , Justin He , Greg Kurz Subject: Re: [PATCH RFC 4/4] 9p: fix race issue in fid contention. Message-ID: <20200914083200.GA9259@nautica> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jianyong Wu wrote on Mon, Sep 14, 2020: > > Not having exceptions for that will also make the code around > > fid_atomic_dec much simpler: just have clunk do an atomic dec and only do > > the actual clunk if that hit zero, and we should be able to get rid of that > > helper? > > Sorry, I think always-one refcount won't work at this point, as the > fid will be clunked only by file context itself not the every consumer > of every fid. We can't decrease the refcounter at just one static > point. > Am I wrong? I don't understand the "We can't decrease the refcounter at just one static point". Basically everywhere you added a fid_atomic_dec() will just need to be changed to clunk -- the basic rule of refcounting is that anywhere you take a ref you need to put it back. All these places take a fid to do some RPC already so it's not a problem to add a clunk and do one more; especially since the "clunk" will just be just a deref. For consistency I'd advocate for the kref API as we use that for requests already; it might be better to rename the clunk calls to p9_fid_put or something but I think that's more churn than it's worth.... Is there anywhere you think cannot do that? > This enum value is not functionally necessary, but I think it can > reduce the contention of fid, as there are really lots of scenarios > that fid from inode is not necessary. I really don't think it makes things slower if done correctly (e.g. no waiting as currently done but the last deref does the actual clunk), and would rather keep code simpler unless the difference is big (so would need to do an actual benchmark of both if you're convinced it helps) -- sorry. >> If possible put the patch first in the series so commits can be >> tested independently. > > Ah, this patch depends on the previous patches, how can I put it as > the first of the series? Basically build the logic in the first patch, then either apply the other three as close as they currently are as possible and add the missing refcalls in a new patch or incorporate the refcounting in them as well. It's fine if you keep it it last, that was just a greedy request on my part to be able to test async clunk more easily ; forget about it. -- Dominique