Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3412881pxv; Mon, 26 Jul 2021 03:44:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtPmHuS04CV2ZoiK0Es2S1OVqUHKrYFONu0WPtdwPkmIPmztTE0giAaoPntCc8PisqJQgv X-Received: by 2002:a05:6e02:de6:: with SMTP id m6mr12828947ilj.203.1627296288134; Mon, 26 Jul 2021 03:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627296288; cv=none; d=google.com; s=arc-20160816; b=REBXyydaQFyjRs1SKiuvP0tRPC4IyaJ2+gqOn5NMfCgN2boSieesrgbOxynR19LEXB Xt2n5UThDoDpbN9lXuCHDaK6Jk3wSfd9rAtXw4Yf950/R/8dl+EreOKIbCkkKTb0upRs cYJiqoWYDIVcLJq1LF22/6nqz1A6rkCwcQEs8nRAud/i/wrEv67Nbwo3lxOjGia6qt1b EcksuZO6hUFi2T2xxEXXaD4xVAwYJYKpNbzD+/XgUkwdSfCc66he3mgQ15pKOqTwCVp/ 3cuCbVz6d/FfsTjQC8VVpEJzxrg1Kmnn9OxURfs0MFW4LAluAF1js8WzzhkoCu3clzSG Vdiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=AkL+3e8jBrNcLRkjbsBpF4y4JNtsRO+AcpLHdmakYls=; b=dgmHHIk/Rbg3R6OfdRTsCwXIwOIMk/uHuDc9qsS5/yWwK0h4GxoWKaYgIUfjCyp0Dn AYa+xwwO7VyoB8rdIXTO52ISJH4TmPGRdZRA/vbZhDIOtX769zhe7y3NqXDMC6bMd3qk M1PgQhGVrAkBRUTX2lZQ2knEtV3LHZKLXNZfbVFUUeUdROe9UPGb8DVr/5gDSi5AZAEt 2t3gL71o+MsW3GcASjh6T0NluYONcasHv6A1ie2Yc9W2MZtI6X3bZef+owPXf4/MYp1Z FQ7l4QNqPM8qe5INL16tUywIN6n8Kh125W4vOpnH+BCoIFgqrjuu3piJVMU59HR+TMHH bNcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="dNIgSn/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y8si3413930ior.35.2021.07.26.03.44.36; Mon, 26 Jul 2021 03:44:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="dNIgSn/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232373AbhGZKC6 (ORCPT + 99 others); Mon, 26 Jul 2021 06:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbhGZKC5 (ORCPT ); Mon, 26 Jul 2021 06:02:57 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 556B5C061757; Mon, 26 Jul 2021 03:43:24 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id da26so9965874edb.1; Mon, 26 Jul 2021 03:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=AkL+3e8jBrNcLRkjbsBpF4y4JNtsRO+AcpLHdmakYls=; b=dNIgSn/VSK9XUHmG020MXHJtiOa1BBuZktZDvQsVM4EXlxWYLk2EblEnR7aFJZNChT vCj2AZlpA0778Rfi7131ebzbWFCoyibOjB+mg9cypa697MB4bhdWI25Ru++ktcTEQojd UUlx6md3ISevOhYLgvoybN8xXOavoVEd23P1DOp9F69+bj4TJYXAIVGEMOtn+KF/r39J 5zIABlmXmT2mWDEcx+ikDqvUW82II6J/8oyFAQuL0+J3dSzjEQtIU1BfSgf5RKiZhFzl 0dxTtZ9YUmtZw03P+1eqwhjYF3+3RXVgRqskF8nYJLG7y8HM3tM3+IBJM5wH0OkHb1HM Whyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=AkL+3e8jBrNcLRkjbsBpF4y4JNtsRO+AcpLHdmakYls=; b=R+w/9gk6sSxr925YNLme2BlJA2JW62xogTmvsSWwR9a5k/TD+ciicvhPMuCNbvclv4 2w4+YtoSuJ9XRfRKKTrQz3ITm8aCKXBOaz4veMgZJAdydbjhNdUnHj3W/3iPnaOAexDW tUf7pSSofoWaWR6UDVandoWcIlKnBcjk8bs4xwb9vMuJzDQBSirq3x37L7Pg+jsXsd7M rnD79Fnab70Ziad5a2EsEx9TsouXZcYrPNtmzCLx1RGcldv5S/qU7r/B2Anu62fw4MDi O41cA5jNLEq42n9EZyVD1DekFOJaCnLH/yRLSTQhPIs6w8DLl1OAX3eYhqKKGWNKjTdh aUfw== X-Gm-Message-State: AOAM533HBF/gMngcuUrf2CWKUHhcW0fkgGWtwI+JvPfCxty9/VtKewPW hE74zFlVHpMCAtC1bezOm1k= X-Received: by 2002:a50:d71e:: with SMTP id t30mr8563995edi.72.1627296202929; Mon, 26 Jul 2021 03:43:22 -0700 (PDT) Received: from ?IPv6:2001:b07:6456:fd99:ced0:db1c:53e1:191e? ([2001:b07:6456:fd99:ced0:db1c:53e1:191e]) by smtp.gmail.com with ESMTPSA id z27sm3092181eja.59.2021.07.26.03.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 03:43:22 -0700 (PDT) Message-ID: Subject: Re: [PATCH 1/3] tools libc_compat: add gettid From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Namhyung Kim , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Date: Mon, 26 Jul 2021 12:43:21 +0200 In-Reply-To: <202107260534.Q3Cd7MYm-lkp@intel.com> References: <309becd325626e04015ad7b5f6fc701e569f918d.1626966805.git.rickyman7@gmail.com> <202107260534.Q3Cd7MYm-lkp@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.2 (3.40.2-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, as reported by the kernel test robot, I forgot to include sys/syscall.h and unistd.h, which were included by some other headers in perf but is causing troubles in the bpf selftest. However, this is not all, since bpf tests are still failing since they do not use HAVE_* macros, therefore gettid gets defined twice (in libc and libc_compat.h). Since, afaict, bpf is no longer using libc_compat.h [1] (perf is be the only user atm), I would remove its dependency on libc_compat.h. Furthermore, this made me also think whether the HAVE_* or NEED_* macros are more suited for this case (reallocarray is using COMPAT_NEED_REALLOCARRAY, gettid is using HAVE_GETTID). I believe HAVE_* are better since compilation fails if they are missing or misused (as in this case), while NEED_* failures may be more subtle (ie. only happening with older versions of libc). Therefore, I think we should also change COMPAT_NEED_REALLOCARRAY to HAVE_REALLOCARRAY. What do you think? [1] https://lore.kernel.org/bpf/20200819013607.3607269-2-andriin@fb.com/ Thanks, Riccardo On Mon, 2021-07-26 at 06:04 +0800, kernel test robot wrote: > Hi Riccardo, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on tip/perf/core] > [also build test ERROR on linux/master linus/master v5.14-rc2 next-20210723] > [If your patch is applied to the wrong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch] > > url:    > https://github.com/0day-ci/linux/commits/Riccardo-Mancini/tools-add-gettid-to-libc_compat-h/20210722-233601 > base:   > https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git c76826a65f50038f0504 > 24365dbf3f97203f8710 > config: x86_64-rhel-8.3-kselftests (attached as .config) > compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 > reproduce (this is a W=1 build): >         # > https://github.com/0day-ci/linux/commit/42df183984cce4c25932242bbf9133684e9425db >         git remote add linux-review https://github.com/0day-ci/linux >         git fetch --no-tags linux-review Riccardo-Mancini/tools-add-gettid-to- > libc_compat-h/20210722-233601 >         git checkout 42df183984cce4c25932242bbf9133684e9425db >         # save the attached .config to linux build tree >         mkdir build_dir >         make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash -C > tools/testing/selftests/bpf install > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > > All errors (new ones prefixed by >>): > >    In file included from main.h:15, >                     from xlated_dumper.c:14: >    tools/include/tools/libc_compat.h: In function 'gettid': >    tools/include/tools/libc_compat.h:24:16: warning: implicit declaration of > function 'syscall' [-Wimplicit-function-declaration] >       24 |  return (pid_t)syscall(__NR_gettid); >          |                ^~~~~~~ > > > tools/include/tools/libc_compat.h:24:24: error: '__NR_gettid' undeclared > > > (first use in this function) >       24 |  return (pid_t)syscall(__NR_gettid); >          |                        ^~~~~~~~~~~ >    tools/include/tools/libc_compat.h:24:24: note: each undeclared identifier is > reported only once for each function it appears in > -- >    In file included from main.h:15, >                     from common.c:27: > > > tools/include/tools/libc_compat.h:22:21: error: static declaration of > > > 'gettid' follows non-static declaration >       22 | static inline pid_t gettid(void) >          |                     ^~~~~~ >    In file included from /usr/include/unistd.h:1170, >                     from common.c:15: >    /usr/include/x86_64-linux-gnu/bits/unistd_ext.h:34:16: note: previous > declaration of 'gettid' was here >       34 | extern __pid_t gettid (void) __THROW; >          |                ^~~~~~ >    In file included from main.h:15, >                     from common.c:27: >    tools/include/tools/libc_compat.h: In function 'gettid': > > > tools/include/tools/libc_compat.h:24:24: error: '__NR_gettid' undeclared > > > (first use in this function) >       24 |  return (pid_t)syscall(__NR_gettid); >          |                        ^~~~~~~~~~~ >    tools/include/tools/libc_compat.h:24:24: note: each undeclared identifier is > reported only once for each function it appears in > -- >    In file included from main.h:15, >                     from btf.c:20: >    tools/include/tools/libc_compat.h: In function 'gettid': > > > tools/include/tools/libc_compat.h:24:24: error: '__NR_gettid' undeclared > > > (first use in this function) >       24 |  return (pid_t)syscall(__NR_gettid); >          |                        ^~~~~~~~~~~ >    tools/include/tools/libc_compat.h:24:24: note: each undeclared identifier is > reported only once for each function it appears in > > > vim +/__NR_gettid +24 tools/include/tools/libc_compat.h > >     20   >     21  #ifndef HAVE_GETTID >   > 22  static inline pid_t gettid(void) >     23  { >   > 24          return (pid_t)syscall(__NR_gettid); > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org