public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: "Abhishek Chauhan (ABC)" <quic_abchauha@quicinc.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Halaney <ahalaney@redhat.com>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>, bpf <bpf@vger.kernel.org>,
	kernel@quicinc.com
Subject: Re: [RFC PATCH bpf-next v5 2/2] net: Add additional bit to support clockid_t timestamp type
Date: Fri, 3 May 2024 14:41:00 -0700	[thread overview]
Message-ID: <8376c566-14a4-4b11-89ba-bb544ee5f8e2@linux.dev> (raw)
In-Reply-To: <0f88ec53-6c92-434d-81c8-538b31a2385e@quicinc.com>

On 5/3/24 2:33 PM, Abhishek Chauhan (ABC) wrote:
> 
>> BPF_CALL_3(bpf_skb_set_tstamp, struct sk_buff *, skb,
>>             u64, tstamp, u32, tstamp_type)
>> {
>>      /* ... */
>>      case BPF_SKB_CLOCK_TAI:
>>          if (!tstamp)
>>              return -EINVAL;
>>          skb->tstamp = tstamp;
>>          skb->tstamp_type = SKB_CLOCK_TAI;
>>          break;
>>          case BPF_SKB_CLOCK_REALTIME:
>>          skb->tstamp = tstamp;
>>          skb->tstamp_type = SKB_CLOCK_REALTIME;
>>          break;
>>
>>      /* ... */
>> }
>>
>>>                return -EINVAL;
>>
>>> @@ -9388,17 +9394,17 @@ static struct bpf_insn *bpf_convert_tstamp_type_read(const struct bpf_insn *si,
>>>    {
>>>        __u8 value_reg = si->dst_reg;
>>>        __u8 skb_reg = si->src_reg;
>>> -    /* AX is needed because src_reg and dst_reg could be the same */
>>> -    __u8 tmp_reg = BPF_REG_AX;
>>> -
>>> -    *insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg,
>>> -                  SKB_BF_MONO_TC_OFFSET);
>>> -    *insn++ = BPF_JMP32_IMM(BPF_JSET, tmp_reg,
>>> -                SKB_MONO_DELIVERY_TIME_MASK, 2);
>>> -    *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_UNSPEC);
>>> -    *insn++ = BPF_JMP_A(1);
>>> -    *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_DELIVERY_MONO);
>>> -
>>> +    BUILD_BUG_ON(__SKB_CLOCK_MAX != BPF_SKB_TSTAMP_DELIVERY_TAI);
>>
>> Add these also:
>>
>>      BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME);
>>      BUILD_BUG_ON(SKB_CLOCK_MONOTONIC != BPF_SKB_CLOCK_MONOTONIC);
>>      BUILD_BUG_ON(SKB_CLOCK_TAI != BPF_SKB_CLOCK_TAI);
>>
> 
> Martin, The above suggestion of adding BUILD_BUG_ON always gives me a warning stating the following.
> 
> Some systems considers warning as error if compiler flags are enabled. I believe this requires your suggestion before i raise RFC v6 patchset to either keep the
> BUILD_BUG_ON or remove it completely.

cast it?

> 
> /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9395:34: warning: comparison between ‘enum skb_tstamp_type’ and ‘enum <anonymous>’ [-Wenum-compare]
>   9395 |  BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME);
>        |                                  ^~
> /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:451:9: note: in definition of macro ‘__compiletime_assert’
>    451 |   if (!(condition))     \
>        |         ^~~~~~~~~
> /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:471:2: note: in expansion of macro ‘_compiletime_assert’
>    471 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>        |  ^~~~~~~~~~~~~~~~~~~
> /local/mnt/workspace/kernel_master/linux-next/include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
>     39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>        |                                     ^~~~~~~~~~~~~~~~~~
> /local/mnt/workspace/kernel_master/linux-next/include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
>     50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>        |  ^~~~~~~~~~~~~~~~
> /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9395:2: note: in expansion of macro ‘BUILD_BUG_ON’
>   9395 |  BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME);
>        |  ^~~~~~~~~~~~
> /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9396:35: warning: comparison between ‘enum skb_tstamp_type’ and ‘enum <anonymous>’ [-Wenum-compare]
>   9396 |  BUILD_BUG_ON(SKB_CLOCK_MONOTONIC != BPF_SKB_CLOCK_MONOTONIC);
>        |                                   ^~
> /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:451:9: note: in definition of macro ‘__compiletime_assert’
>    451 |   if (!(condition))     \
>        |         ^~~~~~~~~
> 
>           |                                      ^~
> 
> 
> 


  reply	other threads:[~2024-05-03 21:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 22:20 [RFC PATCH bpf-next v5 0/2] Replace mono_delivery_time with tstamp_type Abhishek Chauhan
2024-04-24 22:20 ` [RFC PATCH bpf-next v5 1/2] net: Rename mono_delivery_time to tstamp_type for scalabilty Abhishek Chauhan
2024-04-25 14:31   ` Willem de Bruijn
2024-04-25 19:02     ` Abhishek Chauhan (ABC)
2024-04-25 23:50       ` Martin KaFai Lau
2024-04-25 23:55         ` Abhishek Chauhan (ABC)
2024-04-24 22:20 ` [RFC PATCH bpf-next v5 2/2] net: Add additional bit to support clockid_t timestamp type Abhishek Chauhan
2024-04-25 14:42   ` Willem de Bruijn
2024-04-25 19:12     ` Abhishek Chauhan (ABC)
2024-04-26  4:37   ` Martin KaFai Lau
2024-04-26 18:46     ` Abhishek Chauhan (ABC)
2024-04-26 23:50       ` Martin KaFai Lau
2024-04-30 19:16         ` Abhishek Chauhan (ABC)
2024-04-30 20:26           ` Willem de Bruijn
2024-04-30 20:40             ` Abhishek Chauhan (ABC)
2024-05-03 21:33     ` Abhishek Chauhan (ABC)
2024-05-03 21:41       ` Martin KaFai Lau [this message]
2024-05-03 22:14         ` Abhishek Chauhan (ABC)
2024-04-26 23:55   ` Martin KaFai Lau
2024-04-30 19:59     ` Abhishek Chauhan (ABC)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8376c566-14a4-4b11-89ba-bb544ee5f8e2@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=ahalaney@redhat.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel@quicinc.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quic_abchauha@quicinc.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox