From owner-dev-commits-src-main@freebsd.org Fri Sep 10 07:43:09 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6287E6A88D8; Fri, 10 Sep 2021 07:43:09 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H5SXY27x4z4TfJ; Fri, 10 Sep 2021 07:43:09 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lf1-x12d.google.com with SMTP id l11so2296604lfe.1; Fri, 10 Sep 2021 00:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oT5s8+qti6k9hUtBxS5kS4ID9RzWZ8lWdOCoJVDB5R0=; b=BWdWgdzFOhdJDgCYZYOty3cxyoZHHDY+DGBBvoQjbW6ZxZp28b2GhVKCqc0OFl5fDx RhVsMlc9odWAcuYbV2xduYBdpdD/AkxrIWuyO81Q1VtWqEInNKTwfbNW85rlOnWI6q6G 1mzafg5IbxmSC91BbwGk+3dzgyAVD0P6LQf0A8SpOKjRdZJQhspKbR/y1TgjV6jdXHQy Ra4dYyj4SqNwT3xnGhMt0sFBMwdKXTWB2wFzTrdzsnrswDOipzwhsu5s71YXzBDL/rMf 4sukXwIVZ+p/ONixNBKwRUSlAEVFVdgUvJxAZp2RMjwyNECdqMfd4eXedvcAtX6fZb4R Hp1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oT5s8+qti6k9hUtBxS5kS4ID9RzWZ8lWdOCoJVDB5R0=; b=tL8ZKbFnAyPxMexxHERxClPziytSwZWd0J6F03NDkdp0UEfPhpMwXF/I+xTneolvr8 BNXEvZ8uIXjTM6OTCZ68dlpoz095I7DC/JBpdCHH2tV10qjIv2dLksnrI4Zr289froSA MsM0xTReP98UWj9aP0OjnIeOALXit8pahpHYMVYIqx3r7eBVmhHivApc+OULa3XUTQoH ghGmHAvSkmrfhr8eUiJGWQ4P4lBJZbWqyNz0K79hmPZVoU9twU2Po33cFKK0jHlfPfXV D2iK0sKksEAyQylgm1wEgS85lqTEzIjFXRs9FeudGEKVwl+18WCeJta03cfEavgRRGIw H46w== X-Gm-Message-State: AOAM532uP7kPkxFvsZOHURLp0YAMHykRoF7flFLukhE3wN3YzO0qVncP Df6YFRMQBvTG2HZRFxW7gzi5q5eWhOr7zqIyr8TikV8l X-Google-Smtp-Source: ABdhPJzgWBER8ogaWkR3lbf6VUPhrstuZ1H8q7x6U/JG5Zx7jdIAJYs61qv9PiTR9Xuxd28q5SSvG+QCH70Kvw+TJ4k= X-Received: by 2002:a05:6512:1114:: with SMTP id l20mr2982483lfg.550.1631259787529; Fri, 10 Sep 2021 00:43:07 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:6f04:0:0:0:0:0 with HTTP; Fri, 10 Sep 2021 00:43:06 -0700 (PDT) In-Reply-To: References: <202108171959.17HJx2lL069856@gitrepo.freebsd.org> From: Mateusz Guzik Date: Fri, 10 Sep 2021 09:43:06 +0200 Message-ID: Subject: Re: git: 5091ca26507b - main - pf: save on branching in the common case in pf_test To: Gleb Smirnoff Cc: kp@freebsd.org, src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4H5SXY27x4z4TfJ X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Sep 2021 07:43:09 -0000 On 9/10/21, Gleb Smirnoff wrote: > Mateusz, > > On Tue, Aug 17, 2021 at 07:59:02PM +0000, Mateusz Guzik wrote: > M> The branch main has been updated by mjg: > M> > M> URL: > https://cgit.FreeBSD.org/src/commit/?id=5091ca26507b83ebd5ce677dd26bd10e4bad4153 > M> > M> commit 5091ca26507b83ebd5ce677dd26bd10e4bad4153 > M> Author: Mateusz Guzik > M> AuthorDate: 2021-08-17 18:04:31 +0000 > M> Commit: Mateusz Guzik > M> CommitDate: 2021-08-17 19:56:33 +0000 > M> > M> pf: save on branching in the common case in pf_test > M> > M> Reviewed by: kp > M> Sponsored by: Rubicon Communications, LLC ("Netgate") > M> --- > M> sys/netpfil/pf/pf.c | 6 +++--- > M> 1 file changed, 3 insertions(+), 3 deletions(-) > M> > M> diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c > M> index e2dd3eb7c0de..add76c7b98d4 100644 > M> --- a/sys/netpfil/pf/pf.c > M> +++ b/sys/netpfil/pf/pf.c > M> @@ -6151,7 +6151,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, > struct mbuf **m0, struct inpcb * > M> > M> PF_RULES_RLOCK(); > M> > M> - if (ip_divert_ptr != NULL && > M> + if (__predict_false(ip_divert_ptr != NULL) && > > This is an optimization for a setup without divert(4) at cost of > pessimization > for a setup with divert(4). IMHO, __predict_false() predicate should guard > against error paths and other unusual events, not favor one setup over > other. > divert is non-standard and comes with tons of overhead, so I think this is justified. The real fix would be to either implement hot patchable branches or otherwise generate pf_test always (or never) doing divert without having to check for it, but that's far in the future. -- Mateusz Guzik