Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp577313img; Mon, 18 Mar 2019 09:30:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJDBFGMZysSdpyE+PizWpOopE3ZDaFRoqrnRy+kTYZ02ktwyeYeoNh9Oi4WunXeNVS9BLI X-Received: by 2002:a17:902:6b03:: with SMTP id o3mr20662248plk.126.1552926602359; Mon, 18 Mar 2019 09:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552926602; cv=none; d=google.com; s=arc-20160816; b=Vg0j/Ku/dyfHgpV214Er94cFJR1ut5qKTMyutXaECCXVk/093s5aq44ZRZ4f3VATNv f6ntTYNyR3LWUzXCdtU991WHJUDqggEv2SLG+Ayl8d9BISIyH7JU+ftmLNqDVHMvHtQJ QMEb5RoGbZ4ZwCBbVd4Xd+zaKqUGRaRbfYdMSuuR0TDAKVHc2EVdPI1g8gXvC+kZiBf2 msQubjaLlwcR7jfP2YGAtz536G7p2BuZ7Tbr2qbfHMWkuJyo4wUs8Lz2BJCKhtpLFC2V 1JanJyONbdYKYmGlmJ14KslBOlsHbeJXVXyKEAIRXEvIsQLO1eNLcFYjs+f8KwANfCiH 4BLQ== 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:dkim-signature; bh=I4/aNqZ3TeFwtNHzcHEcswGWbN5iU4mf8xjDmq9e6JY=; b=zAiCRX785k3IkcVRQuiCfsWSX7asmfJ3WoR02rIegL8Z5QQJSRoq/W1bJ6XD0HsO2V 0y1uxeAvfn6cRBFFJCemC393kVioHaIU9AdFM6xSQhsvlm/6clIOYl69Lg9tw3YOS80r zdgwp0mQim1bg3yXqDNnzt+esoGOgC0DMHHtPz6rAQF3SUtzObansOaZwEgHH8x+NoJq xoo8ahpHF+9D+oVE5yxGlOitQIf1kob5vuc4dlUC1S+lcww+4oJw5pDogriyUics/tF8 NvlCEgt356op8QxDGvOsAdSOtBzzv+QeKPi+oMUKua37KcUvknF4fSUQpQl6oDkLOTn5 rmZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fomichev-me.20150623.gappssmtp.com header.s=20150623 header.b=wyQUWPUU; 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 j188si5870254pfb.75.2019.03.18.09.29.46; Mon, 18 Mar 2019 09:30:02 -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; dkim=pass header.i=@fomichev-me.20150623.gappssmtp.com header.s=20150623 header.b=wyQUWPUU; 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 S1727740AbfCRQ2Z (ORCPT + 99 others); Mon, 18 Mar 2019 12:28:25 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37775 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727697AbfCRQ2Z (ORCPT ); Mon, 18 Mar 2019 12:28:25 -0400 Received: by mail-pg1-f193.google.com with SMTP id q206so11747954pgq.4 for ; Mon, 18 Mar 2019 09:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=I4/aNqZ3TeFwtNHzcHEcswGWbN5iU4mf8xjDmq9e6JY=; b=wyQUWPUUpk3tYcZBLkT1VRICEObRlaM5LZ0u6Z0S06JP/x5G2M3wJRNECDAKSWvvv5 fZ1uyya7sLB5mK3VCSjqrxz5OG2eVdOF4e0QaLpcRomDTKbjFIRX+h4kmBBt+v1wlZan nAs9oC04e4pKiJKxEvMhNtZ7icfNnl9MwVwpiFE+1dtwXQt/4bnbbxqGeFokLlgyCXDg 4oS1lwKUpn1LiYf0Srcx57FyslD7QGnreWbydi3KYWCtTj/D9+QyXtGtk67QAfI+SeD7 X85wt1E3QskxtCenAZ/UmRnCJq/S2j1B/oezWsSCJZhjaNYXQ3ika+tMsppyFhIoPMZ2 +DUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=I4/aNqZ3TeFwtNHzcHEcswGWbN5iU4mf8xjDmq9e6JY=; b=UJ000wUYcYpOgfaIeAlZMyYa3q+i5ntrflX38zDHfxTAmArHPuAG1pGL4bKiXBfA/k oDs0ez3gP/QsF4k8OpkdkwcPu7ddVzaguwdrta6W9AnmOFsyD2Y4YUnSY8LjFxk1uPfj GIXhi0eqMiKH0I0vTqMeoqq6hlREtTd9gyfmIF0+Gwpxc0t4qbBkch2AAx7bYUHRIhH4 0gqlcuKgynu1ltUj6nz3k8viIYZ4/wWgFTrN4YMdcNYjUM0xtSAD5b13RHuaqbp/Tq7y vX9GT6NN2YFUNz2b6TGGQxyWQ+Ctt691JB5rp8wk7G1br6scvkcfcxZ2hqMvrjDR5Z/J YEkQ== X-Gm-Message-State: APjAAAWhf0l+/iA69yy2OczjrqvAl9WsC3CQhM0sKvArw1b4tpzRlrm8 dEHLIDbDAND7uF0rYY2deC7Xrg== X-Received: by 2002:a63:a04c:: with SMTP id u12mr5415791pgn.131.1552926504111; Mon, 18 Mar 2019 09:28:24 -0700 (PDT) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id k132sm5182705pga.40.2019.03.18.09.28.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Mar 2019 09:28:23 -0700 (PDT) Date: Mon, 18 Mar 2019 09:28:22 -0700 From: Stanislav Fomichev To: Sergey Senozhatsky Cc: Sergey Senozhatsky , Eric Dumazet , netdev , LKML Subject: Re: [PATCH] tcp: don't use __constant_cpu_to_be32 Message-ID: <20190318162822.GB7431@mini-arch.hsd1.ca.comcast.net> References: <20190314061514.19586-1-sergey.senozhatsky@gmail.com> <20190315012012.GA748@jagdpanzerIV> <20190315172428.GB5481@mini-arch.hsd1.ca.comcast.net> <20190316051902.GA27630@tigerII.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190316051902.GA27630@tigerII.localdomain> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/16, Sergey Senozhatsky wrote: > On (03/15/19 10:24), Stanislav Fomichev wrote: > > On 03/15, Sergey Senozhatsky wrote: > > > On (03/14/19 05:42), Eric Dumazet wrote: > > > > > cpu_to_be32() is capable enough to detect __builtin_constant_p() > > > > > and to use an appropriate compile time ___constant_swahb32() > > > > > function. > > See my recent commit a0517a0f7ef23 ("selftests/bpf: use > > __bpf_constant_htons in test_prog.c") where compiler was not smart > > enough to figure it out (you can google similar issues for GCC < 4.8). > > Allow me to disagree. > > The error in a0517a0f7ef23 says > > error: implicit declaration of function '__builtin_bswap16' > > which doesn't sound like "the compiler was not smart". > > Let's look at __swab16 > > 100 #ifdef __HAVE_BUILTIN_BSWAP16__ > 101 #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x)) > 102 #else > 103 #define __swab16(x) \ > 104 (__builtin_constant_p((__u16)(x)) ? \ > 105 ___constant_swab16(x) : \ > 106 __fswab16(x)) > 107 #endif > > We can call __builtin_bswap16() only when the compiler has that builtin, > which is what #ifdef __HAVE_BUILTIN_BSWAP16__ for. > > But this is not what tools/testing/selftests/bpf/bpf_endian.h does > > # define __bpf_ntohs(x) __builtin_bswap16(x) > # define __bpf_htons(x) __builtin_bswap16(x) > > So I sort of suspect that what should have been done was that > __HAVE_BUILTIN_BSWAP16__ ifdef, just like what include/uapi/linux/swab.h > does. That sounds convincing, especially since we have the following in include/linux/compiler-gcc.h: #if GCC_VERSION >= 40800 #define __HAVE_BUILTIN_BSWAP16__ #endif So it does indeed look like it's not __builtin_constant_p, but rather missing __builtin_bswap16 for gcc < 4.8. > > -ss