Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp212768imc; Fri, 15 Mar 2019 22:20:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfuszess8AixhAUIV+ytj+JzZ31B4bgxp0HZt7WgeIXwOPgy0OevhQA8tjX1G74QaTfH25 X-Received: by 2002:aa7:91d7:: with SMTP id z23mr7894791pfa.137.1552713654387; Fri, 15 Mar 2019 22:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552713654; cv=none; d=google.com; s=arc-20160816; b=h5fBshdLTR3rSL9ffFf5hkzmxBc2MtIBkGQrsjmjb7U7dfjEIwB2f74XDje8tITZps r8ez/qyw7ogsImov9r52/ZzMV0GbUZaVjvzrWwekFUpQv/C91osbSor36TuNTVA5HMkj yt+g2Pnxv9FseQHDi1fKtzeFw34PYgDT/gIYurz33s2FEFv3P7+Cw0NMLcqi1wQWjSEt p84ak/ggnucrijC7783OZJSO3UusiiNIkJo54J9Bce6GftHFBDJMKmgd5SezkpD/gwc4 +Spz+4dLwy1ZPJe/TdPXzS9KvoNBWFGCCqINJisJybrhgPKBGPnE40k1Q05IPCW+oJKV bS8w== 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:date:from:dkim-signature; bh=wo1Qc+0+P4jKPHD/LFYya9z4OyeMRrQ0z1ytOoJ5gZ4=; b=pozLvYVtQgRF59vdz8e+Z7EovYpLdXj07bk7U0RZZggKALRi6hCr4r77zGrT/x0wb4 hT7SKTX19/+aEoR4wIb3SAwzJKnwSfCB8Y7dnLCGcvfNKQwEt7El1ypq8Oz2fq3jI8lm B8jYO6USvKoSGovVJcVoURYYeXspShj+Y4chzfAKkm+T4C4clgvFOoJ575YZz7NE9g59 sQUcZiErRZMj2wl6NuG44DXAz9RigoThCFhzrjnujTPtQmMe27glCAnmjbbH4Gzib+oM NJlh9yyV23x2UdSmU5CUppi8a0oe4LIrjoKGNYfFgpKX2765lcx/73q7QGg2SRUQ3hEd k4dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="kKNE/4n5"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j2si3911671pfb.268.2019.03.15.22.20.25; Fri, 15 Mar 2019 22:20:54 -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=@gmail.com header.s=20161025 header.b="kKNE/4n5"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726333AbfCPFTV (ORCPT + 99 others); Sat, 16 Mar 2019 01:19:21 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36074 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbfCPFTU (ORCPT ); Sat, 16 Mar 2019 01:19:20 -0400 Received: by mail-pg1-f196.google.com with SMTP id r124so7849554pgr.3; Fri, 15 Mar 2019 22:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wo1Qc+0+P4jKPHD/LFYya9z4OyeMRrQ0z1ytOoJ5gZ4=; b=kKNE/4n5rIuJ/Zi5YihHdhpe3I01iwqoy9FxGlklicywglGxgONEUfLjO9ATfL37P0 8hiTPEi9YpBaa2coYXzhSFieRkQQClTnEA9i/Mgs4raOXS3apehE8AxiZYbMeAE5/Xp8 tTkupH9UN+00UW5DFZMiMV/XBLiPWJlbqIO5GWYfVJ8cO5ltA7pfEyLA1TdzLLwqqPQN /f5NRVnkmxsOlmI3uLaDuL8AwJ1S/Rj62ErWGT0PsRCC2I4sgDTSAYy+mDEprUyPGXHt H6/mUMqoTMKk9+eqBG9+v5jBOkLe3QBhznOSIPteYDkIbe4NlwsZMyjEKSB9CT6Fs4ne DooQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wo1Qc+0+P4jKPHD/LFYya9z4OyeMRrQ0z1ytOoJ5gZ4=; b=swlsclfVCdLEZ4ZaY0SUlpubd/wyHN2SK87PlGWmnyzcVnDUEUdGvkzSTAtGVQcgNm YLKZa3/vJ1WiHzjM0ObdI7OtIEG/VimSQHFhgAMi/S4MdfxuGrVdZMoNYe5eeQ6IiqfM ABYUXtuU7+ka28BBUppA65xmy+OO8eNHRAXkZF0gFVQfTyCTFduZj8+wZuk1y0U4BcyW Y1VzVcxn0SLIo1wNfLzcDg2jAeYVjKGFT2I5/2fGj6x5DGzcorYU+ZlEUzdZIfHdXfm1 8Y0Nm52ykRqyJqptjAWjYuMSJw+c5Cx7c1u5rhe/yvYM2Cs//uMgGGxQxK+GMLnGCnw5 w3VA== X-Gm-Message-State: APjAAAXT5GLnn9hHsHqp+d76da1H9CpoXuh02s4d0k6zsjevii7kvjnT tb53N+Br0TI4FvKd6Q64fAg= X-Received: by 2002:a63:fe58:: with SMTP id x24mr6992352pgj.255.1552713559786; Fri, 15 Mar 2019 22:19:19 -0700 (PDT) Received: from localhost ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id u13sm5477130pfa.169.2019.03.15.22.19.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2019 22:19:18 -0700 (PDT) From: Sergey Senozhatsky X-Google-Original-From: Sergey Senozhatsky Date: Sat, 16 Mar 2019 14:19:02 +0900 To: Stanislav Fomichev Cc: Sergey Senozhatsky , Eric Dumazet , netdev , LKML , Sergey Senozhatsky Subject: Re: [PATCH] tcp: don't use __constant_cpu_to_be32 Message-ID: <20190316051902.GA27630@tigerII.localdomain> References: <20190314061514.19586-1-sergey.senozhatsky@gmail.com> <20190315012012.GA748@jagdpanzerIV> <20190315172428.GB5481@mini-arch.hsd1.ca.comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190315172428.GB5481@mini-arch.hsd1.ca.comcast.net> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -ss