From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 1D6BE5A0278 for ; Sun, 18 Feb 2024 22:00:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708290043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N6JEsi/yP7JlcM01MFJpIzLsltFSLcWoaROfIbb40lw=; b=WB2qf23X9nCFBZm3hwBDsROgGipGBj5yFPreKTBIWMnC/M4mklGzE4FjHXrTQzXcg/X5xs MZgqWC8UJk6PYmEuAsuxAV9R8UgKMke7IBRacMzL6XX0XTnY2m7pMsoMfcfWfhlsDqbUbC bT8CkH9T44hqtrzrpMUdBNc8f+lU8d8= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-aanZkAtsPcexW7GQUPk3nQ-1; Sun, 18 Feb 2024 16:00:40 -0500 X-MC-Unique: aanZkAtsPcexW7GQUPk3nQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a2f71c9f5d2so192413666b.2 for ; Sun, 18 Feb 2024 13:00:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708290039; x=1708894839; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=N6JEsi/yP7JlcM01MFJpIzLsltFSLcWoaROfIbb40lw=; b=pHajAWvGDZ/Fv/Nii0QCxuXvMMKDEuYhcNHQgXOYiyqzh4/EJEMUnu67tGWfyZ6/KI 4225MirX4/qm4By5gM1jg2KT8ZOVkxQQ9uH1HqY2ecSU+TiJFieB5GdvzV9TmyBrfMmv 268hj1DRI9VFPPbqvBYN5mVjVY7O9IwNWmrILjYZhGT5ShoLaqZuVl09wn9IEgiQIYDO BFWLPSgBwbKDfwLZ9ia3Oeft8xr68Dgs63+2kVhLwX17ZzCvXMX812kZft6ZV02LxhZT jWvmGZ+PqYzaY9MpDdngWeO4C8ju9+9vpeEag5gw24JtwoSnrpaqRFyzquwhHfP0yc61 Weyw== X-Gm-Message-State: AOJu0Yx8y5c69UeDr1H+2uYT5Ru1EARKcyCb+tDycI9CrXDttwr3bRl+ QTKVor2COXfhmFvtl3TGjcJZ00Y9zuPLJNhte9xZ03yw3fbL0Kzp3YBfh9C2/60LGW2TthQqU/x QYwbDy1bLSFyI5lULnxZZyEl5fdFbjJt8P3M/e4GXV0+q+ZkFZw== X-Received: by 2002:a17:906:b191:b0:a3e:9ad2:b555 with SMTP id w17-20020a170906b19100b00a3e9ad2b555mr393390ejy.24.1708290039079; Sun, 18 Feb 2024 13:00:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMeUTYBSh06J3hVcinHdccXu4zfCgUlcqbgFRc5yNJWKcsOfwTuYTBLP1Bh/qDI5UbgbqGjA== X-Received: by 2002:a17:906:b191:b0:a3e:9ad2:b555 with SMTP id w17-20020a170906b19100b00a3e9ad2b555mr393386ejy.24.1708290038810; Sun, 18 Feb 2024 13:00:38 -0800 (PST) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id lm7-20020a170906980700b00a3e799969aesm729595ejb.119.2024.02.18.13.00.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Feb 2024 13:00:38 -0800 (PST) Date: Sun, 18 Feb 2024 22:00:04 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 11/22] flow: Clarify flow entry life cycle, introduce uniform logging Message-ID: <20240218220004.2ed89b84@elisabeth> In-Reply-To: <20240206011734.884138-12-david@gibson.dropbear.id.au> References: <20240206011734.884138-1-david@gibson.dropbear.id.au> <20240206011734.884138-12-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: YN2QEEWKPDHTXPASA7U3R2S7I2PNZPI6 X-Message-ID-Hash: YN2QEEWKPDHTXPASA7U3R2S7I2PNZPI6 X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, 6 Feb 2024 12:17:23 +1100 David Gibson wrote: > Our allocation scheme for flow entries means there are some non-obvious > constraints on when what things can be done with an entry. Add a big doc > comment explaining the life cycle. > > In addition, make a FLOW_START() macro to mark one of the important > transitions. This encourages correct usage, by making it natural to only > access the flow type specific structure after calling it. It also logs > that a new flow has been created, which is useful for debugging. > > We also add logging when a flow's lifecycle ends. This doesn't need a new > helper, because it can only happen either from flow_alloc_cancel() or from > the flow deferred handler. > > Signed-off-by: David Gibson > --- > flow.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++-- > flow.h | 5 ++++ > tcp.c | 15 +++++------ > tcp_splice.c | 11 ++++---- > tcp_splice.h | 5 ++-- > 5 files changed, 94 insertions(+), 18 deletions(-) > > diff --git a/flow.c b/flow.c > index beb9749c..a155b54b 100644 > --- a/flow.c > +++ b/flow.c > @@ -34,6 +34,45 @@ static_assert(ARRAY_SIZE(flow_proto) == FLOW_NUM_TYPES, > > /* Global Flow Table */ > > +/** > + * DOC: Theory of Operation - flow entry life cycle > + * > + * An individual flow table entry moves through these logical states, usually in > + * this order. > + * > + * FREE - Part of the general pool of free flow table entries > + * Operations: > + * - flow_alloc() finds an entry and moves it to ALLOC state > + * > + * ALLOC - A tentatively allocated entry > + * Operations: > + * - flow_alloc_cancel() returns the entry to FREE state > + * - FLOW_START() set the entry's type and moves to START state > + * Caveats: > + * - It's not safe to write fields in the flow entry > + * - It's not safe to allocate other entries with flow_alloc() I'm not entirely sure what you mean here -- is this in the sense of s/other/further/ ? > + * - It's not safe to return to the main epoll loop ..."before FLOW_START() is called on the entry"? -- Stefano