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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F242BC433E0 for ; Tue, 19 Jan 2021 18:57:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A6B020706 for ; Tue, 19 Jan 2021 18:57:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A6B020706 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kaod.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1vLH-0006wG-9y for qemu-devel@archiver.kernel.org; Tue, 19 Jan 2021 13:02:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1ujH-0004Ew-Su for qemu-devel@nongnu.org; Tue, 19 Jan 2021 12:23:46 -0500 Received: from 3.mo51.mail-out.ovh.net ([188.165.32.156]:53853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1ujD-0007O1-BD for qemu-devel@nongnu.org; Tue, 19 Jan 2021 12:23:41 -0500 Received: from mxplan5.mail.ovh.net (unknown [10.108.1.6]) by mo51.mail-out.ovh.net (Postfix) with ESMTPS id 20434252B88; Tue, 19 Jan 2021 18:23:36 +0100 (CET) Received: from kaod.org (37.59.142.106) by DAG8EX1.mxp5.local (172.16.2.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Tue, 19 Jan 2021 18:23:35 +0100 Authentication-Results: garm.ovh; auth=pass (GARM-106R00641765a5d-0846-4a81-8ed4-55313cd88d4f, 9B6877A1159CEF26E29E5BE572491BB707B5295E) smtp.auth=groug@kaod.org X-OVh-ClientIp: 82.253.208.248 Date: Tue, 19 Jan 2021 18:23:34 +0100 From: Greg Kurz To: Christian Schoenebeck Subject: Re: [PATCH 2/3] 9pfs: Convert V9fsFidState::fid_list to QSIMPLEQ Message-ID: <20210119182334.2d3381b5@bahia.lan> In-Reply-To: <2181983.BdRbxLO5hT@silver> References: <20210118142300.801516-1-groug@kaod.org> <1901754.QplClEOiAT@silver> <20210119153407.208c4df7@bahia.lan> <2181983.BdRbxLO5hT@silver> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [37.59.142.106] X-ClientProxiedBy: DAG4EX2.mxp5.local (172.16.2.32) To DAG8EX1.mxp5.local (172.16.2.71) X-Ovh-Tracer-GUID: 6c6a106f-f431-4dbb-99d6-ea790299e4ec X-Ovh-Tracer-Id: 1555712199547984282 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledruddtgddutdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpeffhffvuffkjghfofggtgfgihesthejredtredtvdenucfhrhhomhepifhrvghgucfmuhhriicuoehgrhhouhhgsehkrghougdrohhrgheqnecuggftrfgrthhtvghrnhepfedutdeijeejveehkeeileetgfelteekteehtedtieefffevhffflefftdefleejnecukfhppedtrddtrddtrddtpdefjedrheelrddugedvrddutdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepmhigphhlrghnhedrmhgrihhlrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpehgrhhouhhgsehkrghougdrohhrghdprhgtphhtthhopehqvghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhg Received-SPF: pass client-ip=188.165.32.156; envelope-from=groug@kaod.org; helo=3.mo51.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Tue, 19 Jan 2021 16:28:01 +0100 Christian Schoenebeck wrote: > On Dienstag, 19. Januar 2021 15:34:07 CET Greg Kurz wrote: > > On Tue, 19 Jan 2021 14:31:26 +0100 > > > > Christian Schoenebeck wrote: > > > On Montag, 18. Januar 2021 15:22:59 CET Greg Kurz wrote: > > > > The fid_list is currently open-coded. This doesn't seem to serve any > > > > purpose that cannot be met with QEMU's generic lists. Let's go for a > > > > QSIMPLEQ : this will allow to add new fids at the end of the list and > > > > to improve the logic in v9fs_mark_fids_unreclaim(). > > > > > > > > Signed-off-by: Greg Kurz > > > > > > In general LGTM hence: > > > > > > Reviewed-by: Christian Schoenebeck > > > > > > Some comments below ... > > > > > > > --- > > > > > > > > hw/9pfs/9p.c | 41 ++++++++++++++++++----------------------- > > > > hw/9pfs/9p.h | 4 ++-- > > > > 2 files changed, 20 insertions(+), 25 deletions(-) > > > > > > > > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c > > > > index 37c3379b7462..b65f320e6518 100644 > > > > --- a/hw/9pfs/9p.c > > > > +++ b/hw/9pfs/9p.c > > > > @@ -260,7 +260,7 @@ static V9fsFidState *coroutine_fn get_fid(V9fsPDU > > > > *pdu, > > > > int32_t fid) V9fsFidState *f; > > > > > > > > V9fsState *s = pdu->s; > > > > > > > > - for (f = s->fid_list; f; f = f->next) { > > > > + QSIMPLEQ_FOREACH(f, &s->fid_list, next) { > > > > > > > > BUG_ON(f->clunked); > > > > if (f->fid == fid) { > > > > > > > > /* > > > > > > > > @@ -295,7 +295,7 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t > > > > fid) { > > > > > > > > V9fsFidState *f; > > > > > > > > - for (f = s->fid_list; f; f = f->next) { > > > > + QSIMPLEQ_FOREACH(f, &s->fid_list, next) { > > > > > > > > /* If fid is already there return NULL */ > > > > BUG_ON(f->clunked); > > > > if (f->fid == fid) { > > > > > > > > @@ -311,8 +311,7 @@ static V9fsFidState *alloc_fid(V9fsState *s, int32_t > > > > fid) * reclaim won't close the file descriptor > > > > > > > > */ > > > > > > > > f->flags |= FID_REFERENCED; > > > > > > > > - f->next = s->fid_list; > > > > - s->fid_list = f; > > > > + QSIMPLEQ_INSERT_HEAD(&s->fid_list, f, next); > > > > > > Not related to this series, but I wonder why queue.h wraps everything > > > into: > > > > > > do { > > > > > > ... > > > > > > } while (0); > > > > Note, this is do { ... } while (0) *without* the trailing semi-colon, which > > is the corner stone of this trick. > > Yes, I got that. What I meant was, unless I am missing something, a simple > compound statement (without trailing semi-colon) a.k.a. a 'block' is the more > common way to handle this, like: > > #define QSIMPLEQ_INIT(head) { \ > (head)->sqh_first = NULL; \ > (head)->sqh_last = &(head)->sqh_first; \ > } > No this isn't the more common way because it doesn't work with if...else statements, i.e. if (some_condition) QSIMPLEQ_INIT(&head); else do_some_other_stuff() has illagal syntax because of the semi-colon. Of course, since the QEMU coding styles mandates { } in if...else statements, your suggestion should just work, but do { } while(0) doesn't do harm (compilers optimize that flawlessly) and it is so commonly used elsewhere that I don't think its worth changing. > Third patch tomorrow ... thanks Greg! > > Best regards, > Christian Schoenebeck > >