Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp19017ima; Thu, 14 Mar 2019 18:21:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrkud5dtDjjuxLqQl4+edabge7QzzDt02MEoRSxR6vyK6JlHqZhj5kcsSt5J5xw2yzU9sx X-Received: by 2002:a62:ea08:: with SMTP id t8mr1306123pfh.60.1552612906138; Thu, 14 Mar 2019 18:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552612906; cv=none; d=google.com; s=arc-20160816; b=x2GSNWYgMkiTQHF69bNxrR0BS4qGaJ5mVVslXTYYDQ/Y4cABiNoKy36RKUvFOAYNt3 6Nz/dH0Ue5F0VD7j4C7a//In/nG/ZYpktvV4dSau6I7LSgIZYN84oUSuAJIaYcnNET2R BAQLpF7Tm3sppM67F8gSHKv1a4dov6pzUcCuPM+IPpu9cy/Ybx1l/CzNbKCzx5Nn124n bqGGmkRgxvym91lG6rnvHSi+7csXxY+by4wQFRR65VkkULVXHK0gj6y+bGYF1+a5nTm0 Db8TX7hGtccEm/mHJN9fcex4qoLCrl8NoGKqcUQOklKADd8jz+eFBzExz71etB51FW1G fWeg== 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=/o6EGOEXYK/A646G2m+NIiIqTgtUxZAQFxy/FHk3JcA=; b=MTMBytzanDkG/cJK9WM3UxhAPeJplahlq76rNinFff2BfMdPbOFoTeckVfZpw8AJx4 agzkj2db4gSu18OJlhBwmrAP3KvQQ6oFu1xV3kalBTxLkOfo8BDkt4lfC7bHfeFFiVxp 1/LDCzDQ6rq1g8TzFVxDue+4KeSy7Bo8mizWv1xgcoXi5Pr3rZPlRbOSJEd4Bd5kKnfY Ggot+G5uD1ICmS1fpxbD6YmTPywdj0ZvzvKPzB5/2qTMHsL1TrDNIRE7hQwS9JSzaGXs Ja5P5AI3NSzmdFIrDF2w23nsYTE5nXYU1QOQLXaYaOmL+bSKKWN+1yY54eiZKaLv7gsM yWEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iE6TOBaX; 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 n3si426266plk.108.2019.03.14.18.21.30; Thu, 14 Mar 2019 18:21:46 -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=iE6TOBaX; 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 S1728156AbfCOBUS (ORCPT + 99 others); Thu, 14 Mar 2019 21:20:18 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40244 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727254AbfCOBUR (ORCPT ); Thu, 14 Mar 2019 21:20:17 -0400 Received: by mail-pf1-f195.google.com with SMTP id y124so5066630pfy.7; Thu, 14 Mar 2019 18:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/o6EGOEXYK/A646G2m+NIiIqTgtUxZAQFxy/FHk3JcA=; b=iE6TOBaXLcEOhHT3g2Pnpnx+W4rvA7QMppauIihSEqQEgTOudKKZz1Cf7IGsxv3pa2 vNQryMWj8V+ZWygFGrktsGv0VwpX86wC5q3vKbNYP8NsIKEGJvbzSB5IImgD0DuGUTWj xlofdAKws3i8uFPJUFjxGJvrEiryIMGRwurF6EScu8VPscUU6zZ/EADMyCfw8kNgxT/o EnJNoyf53N9ywZzwnfFafoeYQQabAoyxAihjWmewZ7Tcggv8Fg5V/11a7EkrMK/K1NcA Ma2TSx6ihdKks3sBYOamZaAIdzvLbyRBVgExsX0f6GaJrMMdMeKZkDnuIFW621CWnIRK +6Xw== 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=/o6EGOEXYK/A646G2m+NIiIqTgtUxZAQFxy/FHk3JcA=; b=F7BqOz+m5lJeqGsrrmpnwGw1S1G1p5MsZcBkU0UNIa0jS54EeDl/ue7ATvmMr748xQ mrW71vQlhbkdJmiJ7AGw90VZ64A6eiISZyYOgJpsJ54QFo/M4tFKQ6Q2qa8bev7s6FMR 7EdEnNeeVwsdQwmNaTIrym4aguBUu1DdaoRE9ltFa9A3KGeuA1yh9lnRe8305Fwt11NI w4pcWlwpA/sYDXcP7i9BlFLhOkDIjKZTgiALTHxjhPPzOOo6eSjcjKk5orSj8HhPyiUp A3OVJNIVULvOF0rnNnJJT6rQ7YsItT7fjDMIpeAZSlCiQ8c5ut6rsGWi2tEgtIPaWBaZ Dzug== X-Gm-Message-State: APjAAAXUY4dsOQ6P1bdqjtVB5dP0EkKfnGVXNqXbewqNuSTdI1DmfQiB j0tJC9CzTmgDAbB4D8Pl54A= X-Received: by 2002:a63:2b03:: with SMTP id r3mr819867pgr.1.1552612816442; Thu, 14 Mar 2019 18:20:16 -0700 (PDT) Received: from localhost ([110.70.55.120]) by smtp.gmail.com with ESMTPSA id f15sm539929pgd.74.2019.03.14.18.20.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Mar 2019 18:20:15 -0700 (PDT) Date: Fri, 15 Mar 2019 10:20:12 +0900 From: Sergey Senozhatsky To: Eric Dumazet Cc: Sergey Senozhatsky , netdev , LKML , Sergey Senozhatsky Subject: Re: [PATCH] tcp: don't use __constant_cpu_to_be32 Message-ID: <20190315012012.GA748@jagdpanzerIV> References: <20190314061514.19586-1-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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/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. > > > > So we can use cpu_to_be32() instead of __constant_cpu_to_be32(). > > > I dunno, this is uapi, this might break user space for some funky compiler ? > I do not even know if cpu_to_be32() _is_ uapi. Hmm, excellent point. Looking at if_pppox.h:#define PTT_EOL __cpu_to_be16(0x0000) if_pppox.h:#define PTT_SRV_NAME __cpu_to_be16(0x0101) if_pppox.h:#define PTT_AC_NAME __cpu_to_be16(0x0102) if_pppox.h:#define PTT_HOST_UNIQ __cpu_to_be16(0x0103) if_pppox.h:#define PTT_AC_COOKIE __cpu_to_be16(0x0104) if_pppox.h:#define PTT_VENDOR __cpu_to_be16(0x0105) if_pppox.h:#define PTT_RELAY_SID __cpu_to_be16(0x0110) if_pppox.h:#define PTT_SRV_ERR __cpu_to_be16(0x0201) if_pppox.h:#define PTT_SYS_ERR __cpu_to_be16(0x0202) if_pppox.h:#define PTT_GEN_ERR __cpu_to_be16(0x0203) if_tunnel.h:#define GRE_CSUM __cpu_to_be16(0x8000) if_tunnel.h:#define GRE_ROUTING __cpu_to_be16(0x4000) if_tunnel.h:#define GRE_KEY __cpu_to_be16(0x2000) if_tunnel.h:#define GRE_SEQ __cpu_to_be16(0x1000) if_tunnel.h:#define GRE_STRICT __cpu_to_be16(0x0800) if_tunnel.h:#define GRE_REC __cpu_to_be16(0x0700) if_tunnel.h:#define GRE_ACK __cpu_to_be16(0x0080) if_tunnel.h:#define GRE_FLAGS __cpu_to_be16(0x0078) if_tunnel.h:#define GRE_VERSION __cpu_to_be16(0x0007) if_tunnel.h:#define GRE_VERSION_0 __cpu_to_be16(0x0000) if_tunnel.h:#define GRE_VERSION_1 __cpu_to_be16(0x0001) if_tunnel.h:#define GRE_PROTO_PPP __cpu_to_be16(0x880b) You are right, probably would need __cpu_to_be32, which also does the constant folding. =-=-=-=-= Subject: [PATCH] tcp: don't use __constant_cpu_to_be32 __cpu_to_be32() can detect __builtin_constant_p() at compile time. So we can use __cpu_to_be32() instead of __constant_cpu_to_be32(). Signed-off-by: Sergey Senozhatsky --- include/uapi/linux/tcp.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index 8bb6cc5f3235..cf9c246a59c8 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -70,16 +70,16 @@ union tcp_word_hdr { #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) enum { - TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000), - TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), - TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), - TCP_FLAG_ACK = __constant_cpu_to_be32(0x00100000), - TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000), - TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000), - TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000), - TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), - TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), - TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) + TCP_FLAG_CWR = __cpu_to_be32(0x00800000), + TCP_FLAG_ECE = __cpu_to_be32(0x00400000), + TCP_FLAG_URG = __cpu_to_be32(0x00200000), + TCP_FLAG_ACK = __cpu_to_be32(0x00100000), + TCP_FLAG_PSH = __cpu_to_be32(0x00080000), + TCP_FLAG_RST = __cpu_to_be32(0x00040000), + TCP_FLAG_SYN = __cpu_to_be32(0x00020000), + TCP_FLAG_FIN = __cpu_to_be32(0x00010000), + TCP_RESERVED_BITS = __cpu_to_be32(0x0F000000), + TCP_DATA_OFFSET = __cpu_to_be32(0xF0000000) }; /* -- 2.21.0