Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1047587imm; Wed, 22 Aug 2018 18:06:18 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzXsKNDzntTvxcwWeF57IKjzPqECcs4vIv3iDbCpTVjWXLrkqJLoLhdJgH2MftpmgsDNq8S X-Received: by 2002:a63:e60c:: with SMTP id g12-v6mr54162159pgh.308.1534986378592; Wed, 22 Aug 2018 18:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534986378; cv=none; d=google.com; s=arc-20160816; b=heCBb+V4HnmfH9uDh/4k3BNfJfqZnB8JmC1EC7Ocg3zSpMqIqcfxOWTrb+oxW7uilG c2cllq5O2q9Pf29gCn8oFAw/FT9n8cz6ZMMsQe+XLL7CS5pmNQbsNHUxfOrsRjuXj6T8 +6hfdHMtQGG5EFj7yPYtVUlkbA2UlliT0ie7Ee/ouMmOzudewA1IsKiZHpOsnBFe2tZ0 IBUmKZVRhK99GXgB2yJ8ng/UPR0l/9pfTWBsTyrQ5Z7TvA3xa4qwyX1aGFEKCMIfB4IK vsxL8Oorg4lsRH6cm+NpfpaSzMpnOhs+E36roRLNz/+S6G8QAysuofguX+rxWWymhu+X qXXQ== 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:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=YjVt3BsUEQy0N3CplMZE+S9feU7tUP187os0SjxSrY4=; b=i3pX66fVw8aJvvFWs4LfJhRYTHUW7X4J8gs8J8ryxbWc6+I12CEFBJ1SPbhleH44S3 EbMs6G70DmvywhBs2gYza8maK/aBtRqG3MILlEmEuSiUGhgX0tL7FvqPu/kcAIG+GTaO j8JELabAcoplcMbm5/+oPkeE7lACEHxbkrK3O91TidWQpw/9g6d7sIabPQTtD73NO9OJ y5AkODgzcVq4ddUCC9pCcpNxSMuonuxxgXpLabjQqTM9m34n0BaNBZoQiYo0MCEuepjp xnKi/1UOKFUsIOEUwPQ0U96F9W0mx9Ufk5AwTLqEOJFEk3lJ8rScZE3B4XLQZHtLbl+g iFgw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13-v6si3062535pgr.106.2018.08.22.18.06.02; Wed, 22 Aug 2018 18:06:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbeHWEcI (ORCPT + 99 others); Thu, 23 Aug 2018 00:32:08 -0400 Received: from nautica.notk.org ([91.121.71.147]:49627 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbeHWEcH (ORCPT ); Thu, 23 Aug 2018 00:32:07 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id EE414C009; Thu, 23 Aug 2018 03:04:57 +0200 (CEST) Date: Thu, 23 Aug 2018 03:04:42 +0200 From: Dominique Martinet To: Dave Watson Cc: Doron Roberts-Kedes , Tom Herbert , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] strparser: remove any offset before parsing messages Message-ID: <20180823010442.GA6244@nautica> References: <1534855906-22870-1-git-send-email-asmadeus@codewreck.org> <20180821145321.GA44710@doronrk-mbp> <20180821193655.GA15354@nautica> <20180821211504.GA76892@doronrk-mbp.dhcp.thefacebook.com> <20180821225113.GA6515@nautica> <20180821233549.GA96607@doronrk-mbp.dhcp.thefacebook.com> <20180822004647.GA10656@nautica> <20180822023308.GA5970@doronrk-mbp.dhcp.thefacebook.com> <20180822054707.GA13455@nautica> <20180822183852.jnwlxnz54gbbf6po@davejwatson-mba.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180822183852.jnwlxnz54gbbf6po@davejwatson-mba.dhcp.thefacebook.com> 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 Dave Watson wrote on Wed, Aug 22, 2018: > > I've tried measuring that overhead as well by writing a more complex bpf > > program that would fetch the offset in the skb but for some reason I'm > > reading a 0 offset when it's not zero... well, not like there's much > > choice for this at this point anyway; I don't think we'll do this > > without pull, I'll put that on background. > > For what it is worth we checked the offset in bpf, something > along the lines of Oh, thanks! > > struct kcm_rx_msg { int full_len; int offset;}; > static inline struct kcm_rx_msg *kcm_rx_msg(struct __sk_buff *skb) > { return (struct kcm_rx_msg *)skb->cb;} > > int decode_framing(struct __sk_buff *skb) > { return load_word(skb, kcm_rx_msg(skb)->offset);} So you're taking directly the address at skb->cb but the linux code has this function: static inline struct strp_msg *strp_msg(struct sk_buff *skb) { return (struct strp_msg *)((void *)skb->cb + offsetof(struct qdisc_skb_cb, data)); } and qdisc_skb_cb.data is another 8 bytes in, that would explain I had different results (and now I'm trying your snippet it does work), but I'll have to admit I fail to understand this.... Ok, so 'cb' in __sk_buff is 48 bytes in but 'cb' in sk_buff is 40 bytes in -- I might just start getting annoyed over this, is there a reason for the different offset?! > Although it did puzzle me for a while figuring that out when I ran in > to it. Well, at least it means some people were aware of the problem and worked around it in their own way -- what do you think of pulling instead? I mean, we could just document that "really well" and provide the get-offset function in some header that would be made include-able from bpf.. But right now this isn't really the case. FWIW now I have this version I also don't notice any performance change with the pull on my example, it actually looks like the bpf load_word is slightly slower than pull to access data that is not in the head, but the noise level is pretty bad. Thanks, -- Dominique