Re: [PATCH net] selftests: net: avoid waiting for server in amt.sh forever when it fails.

2024-05-09 Thread Taehee Yoo
On Fri, May 10, 2024 at 1:23 AM Jakub Kicinski  wrote:
>

Hi Jakub,
Thanks a lot for the review and looking into the bug.

> On Wed,  8 May 2024 04:06:43 + Taehee Yoo wrote:
> > In the forwarding testcase, it opens a server and a client with the nc.
> > The server receives the correct message from NC, it prints OK.
> > The server prints FAIL if it receives the wrong message from the client.
> >
> > But If the server can't receive any message, it will not close so
> > the amt.sh waits forever.
> > There are several reasons.
> > 1. crash of smcrouted.
> > 2. Send a message from the client to the server before the server is up.
> >
> > To avoid this problem, the server waits only for 10 seconds.
> > The client sends messages for 10 seconds.
> > If the server is successfully closed, it kills the client.
>
> Since this didn't fix the problem of smcroute crashing I had to take
> a closer look myself.
>
> I filed https://github.com/troglobit/smcroute/issues/207 for smcroute
>

Thank you so much for looking into this bug!
I will test it.

> And sent:
> https://lore.kernel.org/all/20240509161919.3939966-1-k...@kernel.org/
> and
> https://lore.kernel.org/all/20240509161952.3940476-1-k...@kernel.org/
>
> Please don't use netcat in tests in the future. There are two
> incompatible implementations which always cause hard to repro
> issues.

Okay, I will not use netcat in the future.

Thanks a lot!
Taehee Yoo



Re: [PATCH net] selftests: net: avoid waiting for server in amt.sh forever when it fails.

2024-05-09 Thread Taehee Yoo
On Thu, May 9, 2024 at 6:36 PM Paolo Abeni  wrote:
>

Hi Paolo,
Thank you for the review!

> On Wed, 2024-05-08 at 04:06 +, Taehee Yoo wrote:
>
> > @@ -210,40 +217,52 @@ check_features()
> >
> > test_ipv4_forward()
> > {
> > - RESULT4=$(ip netns exec "${LISTENER}" nc -w 1 -l -u 239.0.0.1 4000)
> > + echo "" > $RESULT
> > + bash -c "$(ip netns exec "${LISTENER}" \
> > + timeout 10s > $RESULT)"
> > + RESULT4=$(< $RESULT)
>
> if you instead do:
>
> RESULT4=$(timeout 10s ip netns exec \
> "${LISTENER}" nc -w 1 -l -u 239.0.0.1 4000)
>
> You can avoid the additional tmp file (RESULT)
>

Thanks,
In the recent patch from Jakub, a variable is used instead of a file.

> > if [ "$RESULT4" == "172.17.0.2" ]; then
> > printf "TEST: %-60s [ OK ]\n" "IPv4 amt multicast forwarding"
> > - exit 0
> > else
> > printf "TEST: %-60s [FAIL]\n" "IPv4 amt multicast forwarding"
> > - exit 1
> > fi
> > +
> > }
>
> [...]
>
> > @@ -259,19 +278,17 @@ setup_iptables
> > setup_mcast_routing
> > test_remote_ip
> > test_ipv4_forward &
> > -pid=$!
> > -send_mcast4
> > -wait $pid || err=$?
> > -if [ $err -eq 1 ]; then
> > - ERR=1
> > -fi
> > +spid=$!
> > +send_mcast4 &
> > +cpid=$!
> > +wait $spid
>
> It looks like you don't capture anymore the return code from
> test_ipv4_forward, why?
>
> That will foul the test runner infra to think that this test is always
> successful.
>

You're right,
Sorry, I didn't consider it.
It should not be changed.


> Paolo
>

Thanks a lot!
Taehee Yoo



Re: [PATCH net] selftests: net: avoid waiting for server in amt.sh forever when it fails.

2024-05-09 Thread Taehee Yoo
On Thu, May 9, 2024 at 5:38 PM Simon Horman  wrote:
>

Hi Simon,
Thanks a lot for the review!

> On Wed, May 08, 2024 at 04:06:43AM +, Taehee Yoo wrote:
> > In the forwarding testcase, it opens a server and a client with the nc.
> > The server receives the correct message from NC, it prints OK.
> > The server prints FAIL if it receives the wrong message from the client.
> >
> > But If the server can't receive any message, it will not close so
> > the amt.sh waits forever.
> > There are several reasons.
> > 1. crash of smcrouted.
> > 2. Send a message from the client to the server before the server is up.
> >
> > To avoid this problem, the server waits only for 10 seconds.
> > The client sends messages for 10 seconds.
> > If the server is successfully closed, it kills the client.
> >
> > Fixes: c08e8baea78e ("selftests: add amt interface selftest script")
> > Signed-off-by: Taehee Yoo 
> > ---
> >  tools/testing/selftests/net/amt.sh | 63 +++---
> >  1 file changed, 40 insertions(+), 23 deletions(-)
> >
> > diff --git a/tools/testing/selftests/net/amt.sh 
> > b/tools/testing/selftests/net/amt.sh
> > index 75528788cb95..16641d3dccce 100755
> > --- a/tools/testing/selftests/net/amt.sh
> > +++ b/tools/testing/selftests/net/amt.sh
> > @@ -77,6 +77,7 @@ readonly LISTENER=$(mktemp -u listener-)
> >  readonly GATEWAY=$(mktemp -u gateway-)
> >  readonly RELAY=$(mktemp -u relay-)
> >  readonly SOURCE=$(mktemp -u source-)
> > +readonly RESULT=$(mktemp -p /tmp amt-)
> >  ERR=4
> >  err=0
> >
> > @@ -85,6 +86,10 @@ exit_cleanup()
> >   for ns in "$@"; do
> >   ip netns delete "${ns}" 2>/dev/null || true
> >   done
> > + rm $RESULT
> > + smcpid=$(< $SMCROUTEDIR/amt.pid)
> > + kill $smcpid
> > + rm -rf $SMCROUTEDIR
>
> Hi Taehee Yoo,
>
> I think this cleanup may be executed before SMCROUTEDIR exists.
>
> For consistency with other temp files, perhaps
> perpahps it is best to move the creation of SMCROUTEDIR up
> to where RESULT is instantiated above.
>
> And perhaps the pid handling can be made conditional on the
> existence of $SMCROUTEDIR/amt.pid
>
> if [ -f "$SMCROUTEDIR/amt.pid" ]; then
> ...
> fi
>

Thanks!
I will check a pid file before kills smcrouted.

> >
> >   exit $ERR
> >  }
> > @@ -167,7 +172,9 @@ setup_iptables()
> >
> >  setup_mcast_routing()
> >  {
> > - ip netns exec "${RELAY}" smcrouted
> > + SMCROUTEDIR="$(mktemp -d)"
> > +
> > + ip netns exec "${RELAY}" smcrouted -P $SMCROUTEDIR/amt.pid
> >   ip netns exec "${RELAY}" smcroutectl a relay_src \
> >   172.17.0.2 239.0.0.1 amtr
> >   ip netns exec "${RELAY}" smcroutectl a relay_src \
> > @@ -210,40 +217,52 @@ check_features()
> >
> >  test_ipv4_forward()
> >  {
> > - RESULT4=$(ip netns exec "${LISTENER}" nc -w 1 -l -u 239.0.0.1 4000)
> > + echo "" > $RESULT
> > + bash -c "$(ip netns exec "${LISTENER}" \
> > + timeout 10s nc -w 1 -l -u 239.0.0.1 4000 > $RESULT)"
>
> Hi,
>
> It's unclear to me what the purpose of the bash -c "$(...)" construction is
> here. Can the same be achieved using simply:
>
> ip netns exec "${LISTENER}" \
> timeout 10s nc -w 1 -l -u 239.0.0.1 4000 > $RESULT
>

The purpose of using bash -s was to avoid exiting main bash program
by timeout expiration due to 'set -e' option.
But Jakub avoided that problem by adding (|| true) in the recent patch.


> Also, not strictly related to this patch, it seems a little odd here, and
> elsewhere, to call bash in a /bin/sh script.
>

Oh Thanks,
Shebang should be bash, not sh.
I will fix it.


> > + RESULT4=$(< $RESULT)
> >   if [ "$RESULT4" == "172.17.0.2" ]; then
> >   printf "TEST: %-60s  [ OK ]\n" "IPv4 amt multicast forwarding"
> > - exit 0
> >   else
> >   printf "TEST: %-60s  [FAIL]\n" "IPv4 amt multicast forwarding"
> > - exit 1
> >   fi
> > +
> >  }
>
> ...
>
> >  send_mcast4()
> >  {
> >   sleep 2
> > - ip netns exec "${SOURCE}" bash -c \
> > - 'echo 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' &
> > + for n in {0..10}; do
> > + ip netns exec "${SOURCE}" bash -c \
> > + 'echo 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000'
> > + sleep 1
> > + done
> > +
> >  }
> >
> >  send_mcast6()
> >  {
> >   sleep 2
> > - ip netns exec "${SOURCE}" bash -c \
> > - 'echo 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' &
> > + for n in {0..10}; do
> > + ip netns exec "${SOURCE}" bash -c \
> > + 'echo 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000'
> > + sleep 1
> > + done
> > +
> >  }
> >
> >  check_features
>
> ...
>
> --
> pw-bot: under-review

Thanks a lot!
Taehee Yoo



Re: [PATCH net-next] selftests: net: local_termination: annotate the expected failures

2024-05-09 Thread Jakub Kicinski
On Fri, 10 May 2024 11:15:58 +0800 Hangbin Liu wrote:
> I may missed something, I saw there is already a log_test_xfail() in lib.sh
> 
> log_test_skip()
> {
> RET=$ksft_skip retmsg= log_test "$@"
> }
> 
> log_test_xfail()
> {
> RET=$ksft_xfail retmsg= log_test "$@"
> }
> 
> log_info()
> {
> ...
> }
> 
> Added by a923af1ceee7 ("selftests: forwarding: Convert log_test() to 
> recognize RET values")

Good catch, sorry. Must have had net checked out when I wrote it :(



Re: [PATCH net-next] selftests: net: local_termination: annotate the expected failures

2024-05-09 Thread Hangbin Liu
Hi Jakub,

On Thu, May 09, 2024 at 04:55:53PM -0700, Jakub Kicinski wrote:
> Vladimir said when adding this test:
> 
>   The bridge driver fares particularly badly [...] mainly because
>   it does not implement IFF_UNICAST_FLT.
> 
> See commit 90b9566aa5cd ("selftests: forwarding: add a test for
> local_termination.sh").
> 
> We don't want to hide the known gaps, but having a test which
> always fails prevents us from catching regressions. Report
> the cases we know may fail as XFAIL.
> 
> Signed-off-by: Jakub Kicinski 
> ---
> CC: vladimir.olt...@nxp.com
> CC: sh...@kernel.org
> CC: pe...@nvidia.com
> CC: liuhang...@gmail.com
> CC: bpoir...@nvidia.com
> CC: linux-kselftest@vger.kernel.org
> ---
>  tools/testing/selftests/net/forwarding/lib.sh |  9 
>  .../net/forwarding/local_termination.sh   | 21 ++-
>  2 files changed, 25 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh 
> b/tools/testing/selftests/net/forwarding/lib.sh
> index 3353a1745946..4fe28ab5d8b9 100644
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -605,6 +605,15 @@ log_test_xfail()
>   RET=$ksft_xfail retmsg= log_test "$@"
>  }
>  
> +log_test_xfail()
> +{
> + local test_name=$1
> + local opt_str=$2
> +
> + printf "TEST: %-60s  [XFAIL]\n" "$test_name $opt_str"
> + return 0
> +}
> +

I may missed something, I saw there is already a log_test_xfail() in lib.sh

log_test_skip()
{
RET=$ksft_skip retmsg= log_test "$@"
}

log_test_xfail()
{
RET=$ksft_xfail retmsg= log_test "$@"
}

log_info()
{
...
}

Added by a923af1ceee7 ("selftests: forwarding: Convert log_test() to recognize 
RET values")

Thanks
Hangbin



Re: [PATCH net-next 1/2] selftests: net: fix timestamp not arriving in cmsg_time.sh

2024-05-09 Thread Willem de Bruijn
Jakub Kicinski wrote:
> On slow machines the SND timestamp sometimes doesn't arrive before
> we quit. The test only waits as long as the packet delay, so it's
> easy for a race condition to happen.
> 
> Double the wait but do a bit of polling, once the SND timestamp
> arrives there's no point to wait any longer.
> 
> This fixes the "TXTIME abs" failures on debug kernels, like:
> 
>Case ICMPv4  - TXTIME abs returned '', expected 'OK'
> 
> Signed-off-by: Jakub Kicinski 

Reviewed-by: Willem de Bruijn 

> diff --git a/tools/testing/selftests/net/cmsg_sender.c 
> b/tools/testing/selftests/net/cmsg_sender.c
> index c79e65581dc3..f25268504937 100644
> --- a/tools/testing/selftests/net/cmsg_sender.c
> +++ b/tools/testing/selftests/net/cmsg_sender.c
> @@ -333,16 +333,17 @@ static const char *cs_ts_info2str(unsigned int info)
>   return "unknown";
>  }
>  
> -static void
> +static unsigned long
>  cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, size_t cbuf_sz)
>  {
>   struct sock_extended_err *see;
>   struct scm_timestamping *ts;
> + unsigned int ts_seen = 0;

nit: mixing unsigned long and unsigned int



Re: [PATCH net-next 2/2] selftests: net: increase the delay for relative cmsg_time.sh test

2024-05-09 Thread Willem de Bruijn
Jakub Kicinski wrote:
> Slow machines can delay scheduling of the packets for milliseconds.
> Increase the delay to 8ms if KSFT_MACHINE_SLOW. Try to limit the
> variability by moving setsockopts earlier (before we read time).
> 
> This fixes the "TXTIME rel" failures on debug kernels, like:
> 
>   Case ICMPv4  - TXTIME rel returned '', expected 'OK'
> 
> Signed-off-by: Jakub Kicinski 

Reviewed-by: Willem de Bruijn 



Re: [PATCH v3 29/29] kselftest/riscv: kselftest for user mode cfi

2024-05-09 Thread Charlie Jenkins
On Wed, Apr 03, 2024 at 04:35:17PM -0700, Deepak Gupta wrote:
> Adds kselftest for RISC-V control flow integrity implementation for user
> mode. There is not a lot going on in kernel for enabling landing pad for
> user mode. cfi selftest are intended to be compiled with zicfilp and
> zicfiss enabled compiler. Thus kselftest simply checks if landing pad and
> shadow stack for the binary and process are enabled or not. selftest then
> register a signal handler for SIGSEGV. Any control flow violation are
> reported as SIGSEGV with si_code = SEGV_CPERR. Test will fail on recieving
> any SEGV_CPERR. Shadow stack part has more changes in kernel and thus there
> are separate tests for that
>   - Exercise `map_shadow_stack` syscall
>   - `fork` test to make sure COW works for shadow stack pages
>   - gup tests
> As of today kernel uses FOLL_FORCE when access happens to memory via
> /proc//mem. Not breaking that for shadow stack
>   - signal test. Make sure signal delivery results in token creation on
>   shadow stack and consumes (and verifies) token on sigreturn
> - shadow stack protection test. attempts to write using regular store
> instruction on shadow stack memory must result in access faults
> 
> Signed-off-by: Deepak Gupta 
> ---
>  tools/testing/selftests/riscv/Makefile|   2 +-
>  tools/testing/selftests/riscv/cfi/.gitignore  |   3 +
>  tools/testing/selftests/riscv/cfi/Makefile|  10 +
>  .../testing/selftests/riscv/cfi/cfi_rv_test.h |  83 
>  .../selftests/riscv/cfi/riscv_cfi_test.c  |  82 
>  .../testing/selftests/riscv/cfi/shadowstack.c | 362 ++
>  .../testing/selftests/riscv/cfi/shadowstack.h |  37 ++
>  7 files changed, 578 insertions(+), 1 deletion(-)
>  create mode 100644 tools/testing/selftests/riscv/cfi/.gitignore
>  create mode 100644 tools/testing/selftests/riscv/cfi/Makefile
>  create mode 100644 tools/testing/selftests/riscv/cfi/cfi_rv_test.h
>  create mode 100644 tools/testing/selftests/riscv/cfi/riscv_cfi_test.c
>  create mode 100644 tools/testing/selftests/riscv/cfi/shadowstack.c
>  create mode 100644 tools/testing/selftests/riscv/cfi/shadowstack.h
> 
> diff --git a/tools/testing/selftests/riscv/Makefile 
> b/tools/testing/selftests/riscv/Makefile
> index 4a9ff515a3a0..867e5875b7ce 100644
> --- a/tools/testing/selftests/riscv/Makefile
> +++ b/tools/testing/selftests/riscv/Makefile
> @@ -5,7 +5,7 @@
>  ARCH ?= $(shell uname -m 2>/dev/null || echo not)
>  
>  ifneq (,$(filter $(ARCH),riscv))
> -RISCV_SUBTARGETS ?= hwprobe vector mm
> +RISCV_SUBTARGETS ?= hwprobe vector mm cfi
>  else
>  RISCV_SUBTARGETS :=
>  endif
> diff --git a/tools/testing/selftests/riscv/cfi/.gitignore 
> b/tools/testing/selftests/riscv/cfi/.gitignore
> new file mode 100644
> index ..ce7623f9da28
> --- /dev/null
> +++ b/tools/testing/selftests/riscv/cfi/.gitignore
> @@ -0,0 +1,3 @@
> +cfitests
> +riscv_cfi_test
> +shadowstack
> \ No newline at end of file
> diff --git a/tools/testing/selftests/riscv/cfi/Makefile 
> b/tools/testing/selftests/riscv/cfi/Makefile
> new file mode 100644
> index ..b65f7ff38a32
> --- /dev/null
> +++ b/tools/testing/selftests/riscv/cfi/Makefile
> @@ -0,0 +1,10 @@
> +CFLAGS += -I$(top_srcdir)/tools/include
> +
> +CFLAGS += -march=rv64gc_zicfilp_zicfiss
> +
> +TEST_GEN_PROGS := cfitests
> +
> +include ../../lib.mk
> +
> +$(OUTPUT)/cfitests: riscv_cfi_test.c shadowstack.c
> + $(CC) -o$@ $(CFLAGS) $(LDFLAGS) $^
> diff --git a/tools/testing/selftests/riscv/cfi/cfi_rv_test.h 
> b/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
> new file mode 100644
> index ..fa1cf7183672
> --- /dev/null
> +++ b/tools/testing/selftests/riscv/cfi/cfi_rv_test.h
> @@ -0,0 +1,83 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef SELFTEST_RISCV_CFI_H
> +#define SELFTEST_RISCV_CFI_H
> +#include 
> +#include 
> +#include "shadowstack.h"
> +
> +#define RISCV_CFI_SELFTEST_COUNT RISCV_SHADOW_STACK_TESTS
> +
> +#define CHILD_EXIT_CODE_SSWRITE  10
> +#define CHILD_EXIT_CODE_SIG_TEST 11
> +
> +#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5)   \
> +({   
> \
> + register long _num  __asm__ ("a7") = (num); 
> \
> + register long _arg1 __asm__ ("a0") = (long)(arg1);  \
> + register long _arg2 __asm__ ("a1") = (long)(arg2);  \
> + register long _arg3 __asm__ ("a2") = (long)(arg3);  \
> + register long _arg4 __asm__ ("a3") = (long)(arg4);  \
> + register long _arg5 __asm__ ("a4") = (long)(arg5);  \
> + 
> \
> + __asm__ volatile (  
> \
> +  

[PATCH net-next 2/2] selftests: net: increase the delay for relative cmsg_time.sh test

2024-05-09 Thread Jakub Kicinski
Slow machines can delay scheduling of the packets for milliseconds.
Increase the delay to 8ms if KSFT_MACHINE_SLOW. Try to limit the
variability by moving setsockopts earlier (before we read time).

This fixes the "TXTIME rel" failures on debug kernels, like:

  Case ICMPv4  - TXTIME rel returned '', expected 'OK'

Signed-off-by: Jakub Kicinski 
---
CC: sh...@kernel.org
CC: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/net/cmsg_sender.c | 32 +--
 tools/testing/selftests/net/cmsg_time.sh  |  7 +++--
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/net/cmsg_sender.c 
b/tools/testing/selftests/net/cmsg_sender.c
index f25268504937..b2df05ef71cb 100644
--- a/tools/testing/selftests/net/cmsg_sender.c
+++ b/tools/testing/selftests/net/cmsg_sender.c
@@ -260,15 +260,8 @@ cs_write_cmsg(int fd, struct msghdr *msg, char *cbuf, 
size_t cbuf_sz)
  SOL_IPV6, IPV6_HOPLIMIT, );
 
if (opt.txtime.ena) {
-   struct sock_txtime so_txtime = {
-   .clockid = CLOCK_MONOTONIC,
-   };
__u64 txtime;
 
-   if (setsockopt(fd, SOL_SOCKET, SO_TXTIME,
-  _txtime, sizeof(so_txtime)))
-   error(ERN_SOCKOPT, errno, "setsockopt TXTIME");
-
txtime = time_start_mono.tv_sec * (1000ULL * 1000 * 1000) +
 time_start_mono.tv_nsec +
 opt.txtime.delay * 1000;
@@ -284,13 +277,6 @@ cs_write_cmsg(int fd, struct msghdr *msg, char *cbuf, 
size_t cbuf_sz)
memcpy(CMSG_DATA(cmsg), , sizeof(txtime));
}
if (opt.ts.ena) {
-   __u32 val = SOF_TIMESTAMPING_SOFTWARE |
-   SOF_TIMESTAMPING_OPT_TSONLY;
-
-   if (setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING,
-  , sizeof(val)))
-   error(ERN_SOCKOPT, errno, "setsockopt TIMESTAMPING");
-
cmsg = (struct cmsghdr *)(cbuf + cmsg_len);
cmsg_len += CMSG_SPACE(sizeof(__u32));
if (cbuf_sz < cmsg_len)
@@ -426,6 +412,24 @@ static void ca_set_sockopts(int fd)
setsockopt(fd, SOL_SOCKET, SO_PRIORITY,
   , sizeof(opt.sockopt.priority)))
error(ERN_SOCKOPT, errno, "setsockopt SO_PRIORITY");
+
+   if (opt.txtime.ena) {
+   struct sock_txtime so_txtime = {
+   .clockid = CLOCK_MONOTONIC,
+   };
+
+   if (setsockopt(fd, SOL_SOCKET, SO_TXTIME,
+  _txtime, sizeof(so_txtime)))
+   error(ERN_SOCKOPT, errno, "setsockopt TXTIME");
+   }
+   if (opt.ts.ena) {
+   __u32 val = SOF_TIMESTAMPING_SOFTWARE |
+   SOF_TIMESTAMPING_OPT_TSONLY;
+
+   if (setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING,
+  , sizeof(val)))
+   error(ERN_SOCKOPT, errno, "setsockopt TIMESTAMPING");
+   }
 }
 
 int main(int argc, char *argv[])
diff --git a/tools/testing/selftests/net/cmsg_time.sh 
b/tools/testing/selftests/net/cmsg_time.sh
index af85267ad1e3..1d7e756644bc 100755
--- a/tools/testing/selftests/net/cmsg_time.sh
+++ b/tools/testing/selftests/net/cmsg_time.sh
@@ -66,10 +66,13 @@ for i in "-4 $TGT4" "-6 $TGT6"; do
 awk '/SND/ { if ($3 > 1000) print "OK"; }')
check_result $? "$ts" "OK" "$prot - TXTIME abs"
 
-   ts=$(ip netns exec $NS ./cmsg_sender -p $p $i 1234 -t -d 1000 |
+   [ "$KSFT_MACHINE_SLOW" = yes ] && delay=8000 || delay=1000
+
+   ts=$(ip netns exec $NS ./cmsg_sender -p $p $i 1234 -t -d $delay |
 awk '/SND/ {snd=$3}
  /SCHED/ {sch=$3}
- END { if (snd - sch > 500) print "OK"; }')
+ END { if (snd - sch > '$((delay/2))') print "OK";
+   else print snd, "-", sch, "<", '$((delay/2))'; }')
check_result $? "$ts" "OK" "$prot - TXTIME rel"
 done
 done
-- 
2.45.0




[PATCH net-next 1/2] selftests: net: fix timestamp not arriving in cmsg_time.sh

2024-05-09 Thread Jakub Kicinski
On slow machines the SND timestamp sometimes doesn't arrive before
we quit. The test only waits as long as the packet delay, so it's
easy for a race condition to happen.

Double the wait but do a bit of polling, once the SND timestamp
arrives there's no point to wait any longer.

This fixes the "TXTIME abs" failures on debug kernels, like:

   Case ICMPv4  - TXTIME abs returned '', expected 'OK'

Signed-off-by: Jakub Kicinski 
---
CC: sh...@kernel.org
CC: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/net/cmsg_sender.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/cmsg_sender.c 
b/tools/testing/selftests/net/cmsg_sender.c
index c79e65581dc3..f25268504937 100644
--- a/tools/testing/selftests/net/cmsg_sender.c
+++ b/tools/testing/selftests/net/cmsg_sender.c
@@ -333,16 +333,17 @@ static const char *cs_ts_info2str(unsigned int info)
return "unknown";
 }
 
-static void
+static unsigned long
 cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, size_t cbuf_sz)
 {
struct sock_extended_err *see;
struct scm_timestamping *ts;
+   unsigned int ts_seen = 0;
struct cmsghdr *cmsg;
int i, err;
 
if (!opt.ts.ena)
-   return;
+   return 0;
msg->msg_control = cbuf;
msg->msg_controllen = cbuf_sz;
 
@@ -396,8 +397,11 @@ cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, 
size_t cbuf_sz)
printf(" %5s ts%d %lluus\n",
   cs_ts_info2str(see->ee_info),
   i, rel_time);
+   ts_seen |= 1 << see->ee_info;
}
}
+
+   return ts_seen;
 }
 
 static void ca_set_sockopts(int fd)
@@ -509,10 +513,16 @@ int main(int argc, char *argv[])
err = ERN_SUCCESS;
 
if (opt.ts.ena) {
-   /* Make sure all timestamps have time to loop back */
-   usleep(opt.txtime.delay);
+   unsigned long seen;
+   int i;
 
-   cs_read_cmsg(fd, , cbuf, sizeof(cbuf));
+   /* Make sure all timestamps have time to loop back */
+   for (i = 0; i < 40; i++) {
+   seen = cs_read_cmsg(fd, , cbuf, sizeof(cbuf));
+   if (seen & (1 << SCM_TSTAMP_SND))
+   break;
+   usleep(opt.txtime.delay / 20);
+   }
}
 
 err_out:
-- 
2.45.0




[PATCH v4 66/66] selftests/x86: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Drop #define __USE_GNU too, as it is bad practice and the GNU extensions
aren't actually being used in test_FCMOV, etc. where it is being defined.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/x86/amx.c | 2 --
 tools/testing/selftests/x86/check_initial_reg_state.c | 3 ---
 tools/testing/selftests/x86/corrupt_xstate_header.c   | 3 ---
 tools/testing/selftests/x86/entry_from_vm86.c | 3 ---
 tools/testing/selftests/x86/fsgsbase.c| 2 --
 tools/testing/selftests/x86/fsgsbase_restore.c| 2 --
 tools/testing/selftests/x86/ioperm.c  | 2 --
 tools/testing/selftests/x86/iopl.c| 2 --
 tools/testing/selftests/x86/lam.c | 1 -
 tools/testing/selftests/x86/ldt_gdt.c | 2 --
 tools/testing/selftests/x86/mov_ss_trap.c | 2 --
 tools/testing/selftests/x86/nx_stack.c| 2 --
 tools/testing/selftests/x86/ptrace_syscall.c  | 2 --
 tools/testing/selftests/x86/sigaltstack.c | 2 --
 tools/testing/selftests/x86/sigreturn.c   | 3 ---
 tools/testing/selftests/x86/single_step_syscall.c | 3 ---
 tools/testing/selftests/x86/syscall_arg_fault.c   | 3 ---
 tools/testing/selftests/x86/syscall_numbering.c   | 3 ---
 tools/testing/selftests/x86/sysret_rip.c  | 3 ---
 tools/testing/selftests/x86/sysret_ss_attrs.c | 3 ---
 tools/testing/selftests/x86/test_FCMOV.c  | 4 
 tools/testing/selftests/x86/test_FCOMI.c  | 4 
 tools/testing/selftests/x86/test_FISTTP.c | 4 
 tools/testing/selftests/x86/test_mremap_vdso.c| 1 -
 tools/testing/selftests/x86/test_shadow_stack.c   | 3 ---
 tools/testing/selftests/x86/test_syscall_vdso.c   | 4 
 tools/testing/selftests/x86/test_vsyscall.c   | 3 ---
 tools/testing/selftests/x86/unwind_vdso.c | 3 ---
 tools/testing/selftests/x86/vdso_restorer.c   | 3 ---
 29 files changed, 77 deletions(-)

diff --git a/tools/testing/selftests/x86/amx.c 
b/tools/testing/selftests/x86/amx.c
index 95aad6d8849b..3259362a7117 100644
--- a/tools/testing/selftests/x86/amx.c
+++ b/tools/testing/selftests/x86/amx.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/check_initial_reg_state.c 
b/tools/testing/selftests/x86/check_initial_reg_state.c
index 3bc95f3ed585..0129cdae8abe 100644
--- a/tools/testing/selftests/x86/check_initial_reg_state.c
+++ b/tools/testing/selftests/x86/check_initial_reg_state.c
@@ -3,9 +3,6 @@
  * check_initial_reg_state.c - check that execve sets the correct state
  * Copyright (c) 2014-2016 Andrew Lutomirski
  */
-
-#define _GNU_SOURCE
-
 #include 
 
 unsigned long ax, bx, cx, dx, si, di, bp, sp, flags;
diff --git a/tools/testing/selftests/x86/corrupt_xstate_header.c 
b/tools/testing/selftests/x86/corrupt_xstate_header.c
index cf9ce8fbb656..d2c746149678 100644
--- a/tools/testing/selftests/x86/corrupt_xstate_header.c
+++ b/tools/testing/selftests/x86/corrupt_xstate_header.c
@@ -4,9 +4,6 @@
  *
  * Based on analysis and a test case from Thomas Gleixner.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/entry_from_vm86.c 
b/tools/testing/selftests/x86/entry_from_vm86.c
index d1e919b0c1dc..9fa9d4a847ac 100644
--- a/tools/testing/selftests/x86/entry_from_vm86.c
+++ b/tools/testing/selftests/x86/entry_from_vm86.c
@@ -5,9 +5,6 @@
  *
  * This exercises a few paths that need to special-case vm86 mode.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/fsgsbase.c 
b/tools/testing/selftests/x86/fsgsbase.c
index 8c780cce941d..348134d2cefc 100644
--- a/tools/testing/selftests/x86/fsgsbase.c
+++ b/tools/testing/selftests/x86/fsgsbase.c
@@ -3,8 +3,6 @@
  * fsgsbase.c, an fsgsbase test
  * Copyright (c) 2014-2016 Andy Lutomirski
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/fsgsbase_restore.c 
b/tools/testing/selftests/x86/fsgsbase_restore.c
index 6fffadc51579..88dce47ab8e6 100644
--- a/tools/testing/selftests/x86/fsgsbase_restore.c
+++ b/tools/testing/selftests/x86/fsgsbase_restore.c
@@ -12,8 +12,6 @@
  *
  * This is not part of fsgsbase.c, because that test is 64-bit only.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/ioperm.c 
b/tools/testing/selftests/x86/ioperm.c
index 57ec5e99edb9..07b7c10f8d39 100644
--- a/tools/testing/selftests/x86/ioperm.c
+++ b/tools/testing/selftests/x86/ioperm.c
@@ -3,8 +3,6 @@
  * ioperm.c - Test case for ioperm(2)
  * Copyright (c) 2015 Andrew Lutomirski
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 

[PATCH v4 65/66] selftests/wireguard: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/wireguard/qemu/init.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/wireguard/qemu/init.c 
b/tools/testing/selftests/wireguard/qemu/init.c
index 3e49924dd77e..08113f3c6189 100644
--- a/tools/testing/selftests/wireguard/qemu/init.c
+++ b/tools/testing/selftests/wireguard/qemu/init.c
@@ -2,8 +2,6 @@
 /*
  * Copyright (C) 2015-2019 Jason A. Donenfeld . All Rights 
Reserved.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 64/66] selftests/vDSO: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/vDSO/vdso_test_abi.c  | 1 -
 tools/testing/selftests/vDSO/vdso_test_clock_getres.c | 2 --
 tools/testing/selftests/vDSO/vdso_test_correctness.c  | 3 ---
 3 files changed, 6 deletions(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c 
b/tools/testing/selftests/vDSO/vdso_test_abi.c
index 96d32fd65b42..fb01e6ffb9a0 100644
--- a/tools/testing/selftests/vDSO/vdso_test_abi.c
+++ b/tools/testing/selftests/vDSO/vdso_test_abi.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#define _GNU_SOURCE
 #include 
 #include 
 
diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c 
b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
index 38d46a8bf7cb..f0adb906c8bd 100644
--- a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
+++ b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
@@ -10,8 +10,6 @@
  * Power (32-bit and 64-bit), S390x (32-bit and 64-bit).
  * Might work on other architectures.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c 
b/tools/testing/selftests/vDSO/vdso_test_correctness.c
index e691a3cf1491..c435b7a5b38d 100644
--- a/tools/testing/selftests/vDSO/vdso_test_correctness.c
+++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c
@@ -3,9 +3,6 @@
  * ldt_gdt.c - Test cases for LDT and GDT access
  * Copyright (c) 2011-2015 Andrew Lutomirski
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 63/66] selftests/user_events: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/user_events/abi_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/user_events/abi_test.c 
b/tools/testing/selftests/user_events/abi_test.c
index 7288a05136ba..a1f156dbbd56 100644
--- a/tools/testing/selftests/user_events/abi_test.c
+++ b/tools/testing/selftests/user_events/abi_test.c
@@ -4,8 +4,6 @@
  *
  * Copyright (c) 2022 Beau Belgrave 
  */
-
-#define _GNU_SOURCE
 #include 
 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 62/66] selftests/uevent: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/uevent/uevent_filtering.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/uevent/uevent_filtering.c 
b/tools/testing/selftests/uevent/uevent_filtering.c
index dbe55f3a66f4..e308eaf3fc37 100644
--- a/tools/testing/selftests/uevent/uevent_filtering.c
+++ b/tools/testing/selftests/uevent/uevent_filtering.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 61/66] selftests/tmpfs: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/tmpfs/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/tmpfs/Makefile 
b/tools/testing/selftests/tmpfs/Makefile
index aa11ccc92e5b..3be931e1193f 100644
--- a/tools/testing/selftests/tmpfs/Makefile
+++ b/tools/testing/selftests/tmpfs/Makefile
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 CFLAGS += -Wall -O2
-CFLAGS += -D_GNU_SOURCE
 
 TEST_GEN_PROGS :=
 TEST_GEN_PROGS += bug-link-o-tmpfile
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 60/66] selftests/timens: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/timens/clock_nanosleep.c | 1 -
 tools/testing/selftests/timens/exec.c| 1 -
 tools/testing/selftests/timens/futex.c   | 1 -
 tools/testing/selftests/timens/gettime_perf.c| 1 -
 tools/testing/selftests/timens/procfs.c  | 1 -
 tools/testing/selftests/timens/timens.c  | 1 -
 tools/testing/selftests/timens/timer.c   | 1 -
 tools/testing/selftests/timens/timerfd.c | 1 -
 tools/testing/selftests/timens/vfork_exec.c  | 1 -
 9 files changed, 9 deletions(-)

diff --git a/tools/testing/selftests/timens/clock_nanosleep.c 
b/tools/testing/selftests/timens/clock_nanosleep.c
index 72d41b955fb2..5608f2b519e1 100644
--- a/tools/testing/selftests/timens/clock_nanosleep.c
+++ b/tools/testing/selftests/timens/clock_nanosleep.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 
 #include 
diff --git a/tools/testing/selftests/timens/exec.c 
b/tools/testing/selftests/timens/exec.c
index e40dc5be2f66..7f718a3bb043 100644
--- a/tools/testing/selftests/timens/exec.c
+++ b/tools/testing/selftests/timens/exec.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/timens/futex.c 
b/tools/testing/selftests/timens/futex.c
index 6b2b9264e851..0a5a81939220 100644
--- a/tools/testing/selftests/timens/futex.c
+++ b/tools/testing/selftests/timens/futex.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 
 #include 
diff --git a/tools/testing/selftests/timens/gettime_perf.c 
b/tools/testing/selftests/timens/gettime_perf.c
index 6b13dc277724..9fe6690edd2a 100644
--- a/tools/testing/selftests/timens/gettime_perf.c
+++ b/tools/testing/selftests/timens/gettime_perf.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/timens/procfs.c 
b/tools/testing/selftests/timens/procfs.c
index 1833ca97eb24..7bc389b05799 100644
--- a/tools/testing/selftests/timens/procfs.c
+++ b/tools/testing/selftests/timens/procfs.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/timens/timens.c 
b/tools/testing/selftests/timens/timens.c
index 387220791a05..7941a43155a8 100644
--- a/tools/testing/selftests/timens/timens.c
+++ b/tools/testing/selftests/timens/timens.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/timens/timer.c 
b/tools/testing/selftests/timens/timer.c
index 5e7f0051bd7b..378e058359c1 100644
--- a/tools/testing/selftests/timens/timer.c
+++ b/tools/testing/selftests/timens/timer.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 
 #include 
diff --git a/tools/testing/selftests/timens/timerfd.c 
b/tools/testing/selftests/timens/timerfd.c
index 9edd43d6b2c1..807edb9d83c9 100644
--- a/tools/testing/selftests/timens/timerfd.c
+++ b/tools/testing/selftests/timens/timerfd.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 
 #include 
diff --git a/tools/testing/selftests/timens/vfork_exec.c 
b/tools/testing/selftests/timens/vfork_exec.c
index beb7614941fb..675c6a8b2eed 100644
--- a/tools/testing/selftests/timens/vfork_exec.c
+++ b/tools/testing/selftests/timens/vfork_exec.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 59/66] selftests/thermal: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 .../selftests/thermal/intel/power_floor/power_floor_test.c | 3 ---
 .../selftests/thermal/intel/workload_hint/workload_hint_test.c | 3 ---
 2 files changed, 6 deletions(-)

diff --git 
a/tools/testing/selftests/thermal/intel/power_floor/power_floor_test.c 
b/tools/testing/selftests/thermal/intel/power_floor/power_floor_test.c
index 0326b39a11b9..ce98ab045ae9 100644
--- a/tools/testing/selftests/thermal/intel/power_floor/power_floor_test.c
+++ b/tools/testing/selftests/thermal/intel/power_floor/power_floor_test.c
@@ -1,7 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git 
a/tools/testing/selftests/thermal/intel/workload_hint/workload_hint_test.c 
b/tools/testing/selftests/thermal/intel/workload_hint/workload_hint_test.c
index 217c3a641c53..5153d42754d6 100644
--- a/tools/testing/selftests/thermal/intel/workload_hint/workload_hint_test.c
+++ b/tools/testing/selftests/thermal/intel/workload_hint/workload_hint_test.c
@@ -1,7 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 58/66] selftests/syscall_user_dispatch: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c | 2 --
 tools/testing/selftests/syscall_user_dispatch/sud_test.c  | 2 --
 2 files changed, 4 deletions(-)

diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c 
b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
index 073a03702ff5..758fa910e510 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
@@ -4,8 +4,6 @@
  *
  * Benchmark and test syscall user dispatch
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c 
b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
index d975a6767329..76e8f3d91537 100644
--- a/tools/testing/selftests/syscall_user_dispatch/sud_test.c
+++ b/tools/testing/selftests/syscall_user_dispatch/sud_test.c
@@ -4,8 +4,6 @@
  *
  * Test code for syscall user dispatch
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 57/66] selftests/splice: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/splice/default_file_splice_read.c | 1 -
 tools/testing/selftests/splice/splice_read.c  | 1 -
 2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/splice/default_file_splice_read.c 
b/tools/testing/selftests/splice/default_file_splice_read.c
index a3c6e5672e09..a46c5ffb573d 100644
--- a/tools/testing/selftests/splice/default_file_splice_read.c
+++ b/tools/testing/selftests/splice/default_file_splice_read.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 
 int main(int argc, char **argv)
diff --git a/tools/testing/selftests/splice/splice_read.c 
b/tools/testing/selftests/splice/splice_read.c
index 46dae6a25cfb..418a03837938 100644
--- a/tools/testing/selftests/splice/splice_read.c
+++ b/tools/testing/selftests/splice/splice_read.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 56/66] selftests/sigaltstack: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/sigaltstack/sas.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/sigaltstack/sas.c 
b/tools/testing/selftests/sigaltstack/sas.c
index 07227fab1cc9..36b510de0195 100644
--- a/tools/testing/selftests/sigaltstack/sas.c
+++ b/tools/testing/selftests/sigaltstack/sas.c
@@ -6,8 +6,6 @@
  * If that succeeds, then swapcontext() can be used inside sighandler safely.
  *
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 55/66] selftests/seccomp: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/seccomp/seccomp_benchmark.c | 1 -
 tools/testing/selftests/seccomp/seccomp_bpf.c   | 2 --
 2 files changed, 3 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c 
b/tools/testing/selftests/seccomp/seccomp_benchmark.c
index b83099160fbc..3632a4890da9 100644
--- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
+++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
@@ -2,7 +2,6 @@
  * Strictly speaking, this is not a test. But it can report during test
  * runs so relative performace can be measured.
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c 
b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 783ebce8c4de..972ccc12553e 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -4,8 +4,6 @@
  *
  * Test code for seccomp bpf.
  */
-
-#define _GNU_SOURCE
 #include 
 
 /*
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 54/66] selftests/sched: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/sched/cs_prctl_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/sched/cs_prctl_test.c 
b/tools/testing/selftests/sched/cs_prctl_test.c
index 62fba7356af2..abf907f243b6 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -18,8 +18,6 @@
  * You should have received a copy of the GNU Lesser General Public License
  * along with this library; if not, see .
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 53/66] selftests/safesetid: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/safesetid/safesetid-test.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/safesetid/safesetid-test.c 
b/tools/testing/selftests/safesetid/safesetid-test.c
index eb9bf0aee951..89b9d83b76f6 100644
--- a/tools/testing/selftests/safesetid/safesetid-test.c
+++ b/tools/testing/selftests/safesetid/safesetid-test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 52/66] selftests/rseq: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/rseq/basic_percpu_ops_test.c | 1 -
 tools/testing/selftests/rseq/basic_test.c| 2 --
 tools/testing/selftests/rseq/param_test.c| 1 -
 tools/testing/selftests/rseq/rseq.c  | 2 --
 4 files changed, 6 deletions(-)

diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c 
b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
index 2348d2c20d0a..5961c24ee1ae 100644
--- a/tools/testing/selftests/rseq/basic_percpu_ops_test.c
+++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: LGPL-2.1
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/rseq/basic_test.c 
b/tools/testing/selftests/rseq/basic_test.c
index 295eea16466f..1fed749b4bd7 100644
--- a/tools/testing/selftests/rseq/basic_test.c
+++ b/tools/testing/selftests/rseq/basic_test.c
@@ -2,8 +2,6 @@
 /*
  * Basic test coverage for critical regions and rseq_current_cpu().
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/rseq/param_test.c 
b/tools/testing/selftests/rseq/param_test.c
index 2f37961240ca..48a55d94eb72 100644
--- a/tools/testing/selftests/rseq/param_test.c
+++ b/tools/testing/selftests/rseq/param_test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: LGPL-2.1
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/rseq/rseq.c 
b/tools/testing/selftests/rseq/rseq.c
index 96e812bdf8a4..88602889414c 100644
--- a/tools/testing/selftests/rseq/rseq.c
+++ b/tools/testing/selftests/rseq/rseq.c
@@ -14,8 +14,6 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 51/66] selftests/rlimits: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/rlimits/rlimits-per-userns.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/rlimits/rlimits-per-userns.c 
b/tools/testing/selftests/rlimits/rlimits-per-userns.c
index 26dc949e93ea..e0b4f2af9cee 100644
--- a/tools/testing/selftests/rlimits/rlimits-per-userns.c
+++ b/tools/testing/selftests/rlimits/rlimits-per-userns.c
@@ -2,7 +2,6 @@
 /*
  * Author: Alexey Gladkov 
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 50/66] selftests/riscv: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/riscv/mm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/riscv/mm/Makefile 
b/tools/testing/selftests/riscv/mm/Makefile
index c333263f2b27..4664ed79e20b 100644
--- a/tools/testing/selftests/riscv/mm/Makefile
+++ b/tools/testing/selftests/riscv/mm/Makefile
@@ -3,7 +3,7 @@
 # Originally tools/testing/arm64/abi/Makefile
 
 # Additional include paths needed by kselftest.h and local headers
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
+CFLAGS += -std=gnu99 -I.
 
 TEST_GEN_FILES := mmap_default mmap_bottomup
 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 49/66] selftests/riscv: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/riscv/hwprobe/cbo.c| 1 -
 tools/testing/selftests/riscv/hwprobe/which-cpus.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/riscv/hwprobe/cbo.c 
b/tools/testing/selftests/riscv/hwprobe/cbo.c
index a40541bb7c7d..4de6f63fc537 100644
--- a/tools/testing/selftests/riscv/hwprobe/cbo.c
+++ b/tools/testing/selftests/riscv/hwprobe/cbo.c
@@ -5,7 +5,6 @@
  * Run with 'taskset -c  cbo' to only execute hwprobe on a
  * subset of cpus, as well as only executing the tests on those cpus.
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/riscv/hwprobe/which-cpus.c 
b/tools/testing/selftests/riscv/hwprobe/which-cpus.c
index 82c121412dfc..c3f080861c06 100644
--- a/tools/testing/selftests/riscv/hwprobe/which-cpus.c
+++ b/tools/testing/selftests/riscv/hwprobe/which-cpus.c
@@ -5,7 +5,6 @@
  * Test the RISCV_HWPROBE_WHICH_CPUS flag of hwprobe. Also provides a command
  * line interface to get the cpu list for arbitrary hwprobe pairs.
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 48/66] selftests/resctrl: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Acked-by: Reinette Chatre 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/resctrl/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/resctrl/Makefile 
b/tools/testing/selftests/resctrl/Makefile
index 021863f86053..f408bd6bfc3d 100644
--- a/tools/testing/selftests/resctrl/Makefile
+++ b/tools/testing/selftests/resctrl/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
+CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2
 CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := resctrl_tests
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 47/66] selftests/ptp: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/ptp/testptp.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/ptp/testptp.c 
b/tools/testing/selftests/ptp/testptp.c
index 011252fe238c..ea3c48b97468 100644
--- a/tools/testing/selftests/ptp/testptp.c
+++ b/tools/testing/selftests/ptp/testptp.c
@@ -4,7 +4,6 @@
  *
  * Copyright (C) 2010 OMICRON electronics GmbH
  */
-#define _GNU_SOURCE
 #define __SANE_USERSPACE_TYPES__/* For PPC64, to get LL64 types */
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 46/66] selftests/proc: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/proc/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/proc/Makefile 
b/tools/testing/selftests/proc/Makefile
index cd95369254c0..25c34cc9238e 100644
--- a/tools/testing/selftests/proc/Makefile
+++ b/tools/testing/selftests/proc/Makefile
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 CFLAGS += -Wall -O2 -Wno-unused-function
-CFLAGS += -D_GNU_SOURCE
 LDFLAGS += -pthread
 
 TEST_GEN_PROGS :=
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 45/66] selftests/proc: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/proc/proc-empty-vm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/testing/selftests/proc/proc-empty-vm.c 
b/tools/testing/selftests/proc/proc-empty-vm.c
index 56198d4ca2bf..f92a8dce58cf 100644
--- a/tools/testing/selftests/proc/proc-empty-vm.c
+++ b/tools/testing/selftests/proc/proc-empty-vm.c
@@ -23,9 +23,6 @@
  * /proc/${pid}/smaps
  * /proc/${pid}/smaps_rollup
  */
-#undef _GNU_SOURCE
-#define _GNU_SOURCE
-
 #undef NDEBUG
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 44/66] selftests/powerpc: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/powerpc/benchmarks/context_switch.c| 2 --
 tools/testing/selftests/powerpc/benchmarks/exec_target.c   | 2 --
 tools/testing/selftests/powerpc/benchmarks/fork.c  | 2 --
 tools/testing/selftests/powerpc/benchmarks/futex_bench.c   | 3 ---
 tools/testing/selftests/powerpc/dexcr/hashchk_test.c   | 3 ---
 tools/testing/selftests/powerpc/dscr/dscr_default_test.c   | 3 ---
 tools/testing/selftests/powerpc/dscr/dscr_explicit_test.c  | 3 ---
 tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c  | 1 -
 tools/testing/selftests/powerpc/mm/exec_prot.c | 2 --
 tools/testing/selftests/powerpc/mm/pkey_exec_prot.c| 2 --
 tools/testing/selftests/powerpc/mm/pkey_siginfo.c  | 2 --
 tools/testing/selftests/powerpc/mm/tlbie_test.c| 2 --
 tools/testing/selftests/powerpc/papr_vpd/papr_vpd.c| 1 -
 tools/testing/selftests/powerpc/pmu/count_instructions.c   | 3 ---
 tools/testing/selftests/powerpc/pmu/count_stcx_fail.c  | 3 ---
 tools/testing/selftests/powerpc/pmu/ebb/ebb.c  | 3 ---
 .../testing/selftests/powerpc/pmu/ebb/instruction_count_test.c | 3 ---
 tools/testing/selftests/powerpc/pmu/event.c| 2 --
 tools/testing/selftests/powerpc/pmu/lib.c  | 3 ---
 tools/testing/selftests/powerpc/pmu/per_event_excludes.c   | 3 ---
 tools/testing/selftests/powerpc/ptrace/perf-hwbreak.c  | 3 ---
 tools/testing/selftests/powerpc/ptrace/ptrace-syscall.c| 2 --
 tools/testing/selftests/powerpc/signal/sig_sc_double_restart.c | 1 -
 tools/testing/selftests/powerpc/signal/sigreturn_kernel.c  | 3 ---
 tools/testing/selftests/powerpc/signal/sigreturn_vdso.c| 3 ---
 tools/testing/selftests/powerpc/syscalls/ipc_unmuxed.c | 2 --
 tools/testing/selftests/powerpc/tm/tm-exec.c   | 2 --
 tools/testing/selftests/powerpc/tm/tm-poison.c | 2 --
 .../testing/selftests/powerpc/tm/tm-signal-context-force-tm.c  | 2 --
 tools/testing/selftests/powerpc/tm/tm-signal-sigreturn-nt.c| 2 --
 tools/testing/selftests/powerpc/tm/tm-tmspr.c  | 2 --
 tools/testing/selftests/powerpc/tm/tm-trap.c   | 2 --
 tools/testing/selftests/powerpc/tm/tm-unavailable.c| 2 --
 tools/testing/selftests/powerpc/utils.c| 3 ---
 34 files changed, 79 deletions(-)

diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c 
b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
index 96554e2794d1..0b245572bd45 100644
--- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c
+++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
@@ -4,8 +4,6 @@
  *
  * Copyright (C) 2015 Anton Blanchard , IBM
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/powerpc/benchmarks/exec_target.c 
b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
index c14b0fc1edde..8646540037d8 100644
--- a/tools/testing/selftests/powerpc/benchmarks/exec_target.c
+++ b/tools/testing/selftests/powerpc/benchmarks/exec_target.c
@@ -5,8 +5,6 @@
  *
  * Copyright 2018, Anton Blanchard, IBM Corp.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 
diff --git a/tools/testing/selftests/powerpc/benchmarks/fork.c 
b/tools/testing/selftests/powerpc/benchmarks/fork.c
index d312e638cb37..327231646a2a 100644
--- a/tools/testing/selftests/powerpc/benchmarks/fork.c
+++ b/tools/testing/selftests/powerpc/benchmarks/fork.c
@@ -5,8 +5,6 @@
  *
  * Copyright 2018, Anton Blanchard, IBM Corp.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/powerpc/benchmarks/futex_bench.c 
b/tools/testing/selftests/powerpc/benchmarks/futex_bench.c
index 017057090490..0483a13c88f9 100644
--- a/tools/testing/selftests/powerpc/benchmarks/futex_bench.c
+++ b/tools/testing/selftests/powerpc/benchmarks/futex_bench.c
@@ -2,9 +2,6 @@
 /*
  * Copyright 2016, Anton Blanchard, Michael Ellerman, IBM Corp.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/powerpc/dexcr/hashchk_test.c 
b/tools/testing/selftests/powerpc/dexcr/hashchk_test.c
index 645224bdc142..2499ab7fe563 100644
--- a/tools/testing/selftests/powerpc/dexcr/hashchk_test.c
+++ b/tools/testing/selftests/powerpc/dexcr/hashchk_test.c
@@ -1,7 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0+
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_default_test.c 
b/tools/testing/selftests/powerpc/dscr/dscr_default_test.c
index 60ab02525b79..fe6aff1e5dad 100644
--- a/tools/testing/selftests/powerpc/dscr/dscr_default_test.c
+++ b/tools/testing/selftests/powerpc/dscr/dscr_default_test.c
@@ -9,9 +9,6 @@
  * Copyright 

[PATCH v4 43/66] selftests/ptrace: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/ptrace/get_set_sud.c | 1 -
 tools/testing/selftests/ptrace/peeksiginfo.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/ptrace/get_set_sud.c 
b/tools/testing/selftests/ptrace/get_set_sud.c
index 5297b10d25c3..054a78ebe8b5 100644
--- a/tools/testing/selftests/ptrace/get_set_sud.c
+++ b/tools/testing/selftests/ptrace/get_set_sud.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include "../kselftest_harness.h"
 #include 
 #include 
diff --git a/tools/testing/selftests/ptrace/peeksiginfo.c 
b/tools/testing/selftests/ptrace/peeksiginfo.c
index a6884f66dc01..1b7b77190f72 100644
--- a/tools/testing/selftests/ptrace/peeksiginfo.c
+++ b/tools/testing/selftests/ptrace/peeksiginfo.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 42/66] selftests/pidfd: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/pidfd/pidfd.h | 1 -
 tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 2 --
 tools/testing/selftests/pidfd/pidfd_getfd_test.c  | 2 --
 tools/testing/selftests/pidfd/pidfd_open_test.c   | 2 --
 tools/testing/selftests/pidfd/pidfd_poll_test.c   | 2 --
 tools/testing/selftests/pidfd/pidfd_setns_test.c  | 2 --
 tools/testing/selftests/pidfd/pidfd_test.c| 2 --
 tools/testing/selftests/pidfd/pidfd_wait.c| 2 --
 8 files changed, 15 deletions(-)

diff --git a/tools/testing/selftests/pidfd/pidfd.h 
b/tools/testing/selftests/pidfd/pidfd.h
index 88d6830ee004..e33177b1aa41 100644
--- a/tools/testing/selftests/pidfd/pidfd.h
+++ b/tools/testing/selftests/pidfd/pidfd.h
@@ -3,7 +3,6 @@
 #ifndef __PIDFD_H
 #define __PIDFD_H
 
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c 
b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
index f062a986e382..84135d75ece7 100644
--- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/pidfd/pidfd_getfd_test.c 
b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
index cd51d547b751..b6a0e9b3d2f5 100644
--- a/tools/testing/selftests/pidfd/pidfd_getfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/pidfd/pidfd_open_test.c 
b/tools/testing/selftests/pidfd/pidfd_open_test.c
index c62564c264b1..f6735eca1dab 100644
--- a/tools/testing/selftests/pidfd/pidfd_open_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_open_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/pidfd/pidfd_poll_test.c 
b/tools/testing/selftests/pidfd/pidfd_poll_test.c
index 55d74a50358f..83af8489c88e 100644
--- a/tools/testing/selftests/pidfd/pidfd_poll_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_poll_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c 
b/tools/testing/selftests/pidfd/pidfd_setns_test.c
index 47746b0c6acd..518051f0c3a1 100644
--- a/tools/testing/selftests/pidfd/pidfd_setns_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/pidfd/pidfd_test.c 
b/tools/testing/selftests/pidfd/pidfd_test.c
index 9faa686f90e4..53cce08a2202 100644
--- a/tools/testing/selftests/pidfd/pidfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_test.c
@@ -1,6 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/pidfd/pidfd_wait.c 
b/tools/testing/selftests/pidfd/pidfd_wait.c
index 0dcb8365ddc3..54beba0983f1 100644
--- a/tools/testing/selftests/pidfd/pidfd_wait.c
+++ b/tools/testing/selftests/pidfd/pidfd_wait.c
@@ -1,6 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 41/66] selftests/pid_namespace: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/pid_namespace/regression_enomem.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/pid_namespace/regression_enomem.c 
b/tools/testing/selftests/pid_namespace/regression_enomem.c
index 7d84097ad45c..54dc8f16d92a 100644
--- a/tools/testing/selftests/pid_namespace/regression_enomem.c
+++ b/tools/testing/selftests/pid_namespace/regression_enomem.c
@@ -1,4 +1,3 @@
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 40/66] selftests/perf_events: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/perf_events/remove_on_exec.c   | 2 --
 tools/testing/selftests/perf_events/sigtrap_threads.c  | 2 --
 tools/testing/selftests/perf_events/watermark_signal.c | 2 --
 3 files changed, 6 deletions(-)

diff --git a/tools/testing/selftests/perf_events/remove_on_exec.c 
b/tools/testing/selftests/perf_events/remove_on_exec.c
index 5814611a1dc7..ef4d923f4759 100644
--- a/tools/testing/selftests/perf_events/remove_on_exec.c
+++ b/tools/testing/selftests/perf_events/remove_on_exec.c
@@ -5,8 +5,6 @@
  * Copyright (C) 2021, Google LLC.
  */
 
-#define _GNU_SOURCE
-
 /* We need the latest siginfo from the kernel repo. */
 #include 
 #include 
diff --git a/tools/testing/selftests/perf_events/sigtrap_threads.c 
b/tools/testing/selftests/perf_events/sigtrap_threads.c
index d1d8483ac628..14d1a3c8cb5c 100644
--- a/tools/testing/selftests/perf_events/sigtrap_threads.c
+++ b/tools/testing/selftests/perf_events/sigtrap_threads.c
@@ -5,8 +5,6 @@
  * Copyright (C) 2021, Google LLC.
  */
 
-#define _GNU_SOURCE
-
 /* We need the latest siginfo from the kernel repo. */
 #include 
 #include 
diff --git a/tools/testing/selftests/perf_events/watermark_signal.c 
b/tools/testing/selftests/perf_events/watermark_signal.c
index 49dc1e831174..19557bd16e9e 100644
--- a/tools/testing/selftests/perf_events/watermark_signal.c
+++ b/tools/testing/selftests/perf_events/watermark_signal.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 39/66] selftests/openat2: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/openat2/helpers.c| 2 --
 tools/testing/selftests/openat2/helpers.h| 1 -
 tools/testing/selftests/openat2/openat2_test.c   | 2 --
 tools/testing/selftests/openat2/rename_attack_test.c | 2 --
 tools/testing/selftests/openat2/resolve_test.c   | 2 --
 5 files changed, 9 deletions(-)

diff --git a/tools/testing/selftests/openat2/helpers.c 
b/tools/testing/selftests/openat2/helpers.c
index 5074681ffdc9..3658722c889c 100644
--- a/tools/testing/selftests/openat2/helpers.c
+++ b/tools/testing/selftests/openat2/helpers.c
@@ -3,8 +3,6 @@
  * Author: Aleksa Sarai 
  * Copyright (C) 2018-2019 SUSE LLC.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/openat2/helpers.h 
b/tools/testing/selftests/openat2/helpers.h
index 7056340b9339..ecd20a3d47ee 100644
--- a/tools/testing/selftests/openat2/helpers.h
+++ b/tools/testing/selftests/openat2/helpers.h
@@ -7,7 +7,6 @@
 #ifndef __RESOLVEAT_H__
 #define __RESOLVEAT_H__
 
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/openat2/openat2_test.c 
b/tools/testing/selftests/openat2/openat2_test.c
index 9024754530b2..51f1a7d16cc9 100644
--- a/tools/testing/selftests/openat2/openat2_test.c
+++ b/tools/testing/selftests/openat2/openat2_test.c
@@ -3,8 +3,6 @@
  * Author: Aleksa Sarai 
  * Copyright (C) 2018-2019 SUSE LLC.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/openat2/rename_attack_test.c 
b/tools/testing/selftests/openat2/rename_attack_test.c
index 0a770728b436..477125eb64e2 100644
--- a/tools/testing/selftests/openat2/rename_attack_test.c
+++ b/tools/testing/selftests/openat2/rename_attack_test.c
@@ -3,8 +3,6 @@
  * Author: Aleksa Sarai 
  * Copyright (C) 2018-2019 SUSE LLC.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/openat2/resolve_test.c 
b/tools/testing/selftests/openat2/resolve_test.c
index bbafad440893..48fa772de13e 100644
--- a/tools/testing/selftests/openat2/resolve_test.c
+++ b/tools/testing/selftests/openat2/resolve_test.c
@@ -3,8 +3,6 @@
  * Author: Aleksa Sarai 
  * Copyright (C) 2018-2019 SUSE LLC.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 38/66] selftests/nsfs: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/nsfs/owner.c | 1 -
 tools/testing/selftests/nsfs/pidns.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/nsfs/owner.c 
b/tools/testing/selftests/nsfs/owner.c
index 96a976c74550..975834ef42aa 100644
--- a/tools/testing/selftests/nsfs/owner.c
+++ b/tools/testing/selftests/nsfs/owner.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/nsfs/pidns.c 
b/tools/testing/selftests/nsfs/pidns.c
index e3c772c6a7c7..9136fcaf3f40 100644
--- a/tools/testing/selftests/nsfs/pidns.c
+++ b/tools/testing/selftests/nsfs/pidns.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 37/66] selftests/nolibc: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/nolibc/nolibc-test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c 
b/tools/testing/selftests/nolibc/nolibc-test.c
index 94bb6e11c16f..a28813f4367f 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -1,6 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
 #define _LARGEFILE64_SOURCE
 
 /* libc-specific include files
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 36/66] selftests/net: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/net/tcp_ao/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/tcp_ao/Makefile 
b/tools/testing/selftests/net/tcp_ao/Makefile
index 522d991e310e..c608b1ec02e6 100644
--- a/tools/testing/selftests/net/tcp_ao/Makefile
+++ b/tools/testing/selftests/net/tcp_ao/Makefile
@@ -26,7 +26,7 @@ LIB   := $(LIBDIR)/libaotst.a
 LDLIBS += $(LIB) -pthread
 LIBDEPS:= lib/aolib.h Makefile
 
-CFLAGS := -Wall -O2 -g -D_GNU_SOURCE -fno-strict-aliasing
+CFLAGS := -Wall -O2 -g -fno-strict-aliasing
 CFLAGS += $(KHDR_INCLUDES)
 CFLAGS += -iquote ./lib/ -I ../../../../include/
 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 35/66] selftests/net: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/net/af_unix/diag_uid.c   | 2 --
 tools/testing/selftests/net/af_unix/scm_pidfd.c  | 1 -
 tools/testing/selftests/net/af_unix/scm_rights.c | 1 -
 tools/testing/selftests/net/af_unix/unix_connect.c   | 2 --
 tools/testing/selftests/net/csum.c   | 3 ---
 tools/testing/selftests/net/gro.c| 3 ---
 tools/testing/selftests/net/ip_defrag.c  | 3 ---
 tools/testing/selftests/net/ipsec.c  | 3 ---
 tools/testing/selftests/net/ipv6_flowlabel.c | 3 ---
 tools/testing/selftests/net/ipv6_flowlabel_mgr.c | 3 ---
 tools/testing/selftests/net/mptcp/mptcp_connect.c| 3 ---
 tools/testing/selftests/net/mptcp/mptcp_inq.c| 3 ---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c| 3 ---
 tools/testing/selftests/net/msg_zerocopy.c   | 3 ---
 tools/testing/selftests/net/netfilter/audit_logread.c| 2 --
 tools/testing/selftests/net/netfilter/conntrack_dump_flush.c | 3 ---
 tools/testing/selftests/net/nettest.c| 2 --
 tools/testing/selftests/net/psock_fanout.c   | 3 ---
 tools/testing/selftests/net/psock_snd.c  | 3 ---
 tools/testing/selftests/net/reuseport_addr_any.c | 3 ---
 tools/testing/selftests/net/reuseport_bpf_cpu.c  | 3 ---
 tools/testing/selftests/net/reuseport_bpf_numa.c | 3 ---
 tools/testing/selftests/net/reuseport_dualstack.c| 3 ---
 tools/testing/selftests/net/so_incoming_cpu.c| 1 -
 tools/testing/selftests/net/so_netns_cookie.c| 1 -
 tools/testing/selftests/net/so_txtime.c  | 3 ---
 tools/testing/selftests/net/tap.c| 3 ---
 tools/testing/selftests/net/tcp_fastopen_backup_key.c| 1 -
 tools/testing/selftests/net/tcp_inq.c| 2 --
 tools/testing/selftests/net/tcp_mmap.c   | 1 -
 tools/testing/selftests/net/tls.c| 3 ---
 tools/testing/selftests/net/toeplitz.c   | 3 ---
 tools/testing/selftests/net/tun.c| 3 ---
 tools/testing/selftests/net/txring_overwrite.c   | 3 ---
 tools/testing/selftests/net/txtimestamp.c| 3 ---
 tools/testing/selftests/net/udpgso.c | 3 ---
 tools/testing/selftests/net/udpgso_bench_rx.c| 3 ---
 tools/testing/selftests/net/udpgso_bench_tx.c| 3 ---
 38 files changed, 97 deletions(-)

diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c 
b/tools/testing/selftests/net/af_unix/diag_uid.c
index 79a3dd75590e..279d0c5f70d3 100644
--- a/tools/testing/selftests/net/af_unix/diag_uid.c
+++ b/tools/testing/selftests/net/af_unix/diag_uid.c
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright Amazon.com Inc. or its affiliates. */
-
-#define _GNU_SOURCE
 #include 
 
 #include 
diff --git a/tools/testing/selftests/net/af_unix/scm_pidfd.c 
b/tools/testing/selftests/net/af_unix/scm_pidfd.c
index 7e534594167e..2986b8cd0418 100644
--- a/tools/testing/selftests/net/af_unix/scm_pidfd.c
+++ b/tools/testing/selftests/net/af_unix/scm_pidfd.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0 OR MIT
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/net/af_unix/scm_rights.c 
b/tools/testing/selftests/net/af_unix/scm_rights.c
index bab606c9f1eb..146a8d7a8cd9 100644
--- a/tools/testing/selftests/net/af_unix/scm_rights.c
+++ b/tools/testing/selftests/net/af_unix/scm_rights.c
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright Amazon.com Inc. or its affiliates. */
-#define _GNU_SOURCE
 #include 
 
 #include 
diff --git a/tools/testing/selftests/net/af_unix/unix_connect.c 
b/tools/testing/selftests/net/af_unix/unix_connect.c
index d799fd8f5c7c..34e816862cc7 100644
--- a/tools/testing/selftests/net/af_unix/unix_connect.c
+++ b/tools/testing/selftests/net/af_unix/unix_connect.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 
 #include 
diff --git a/tools/testing/selftests/net/csum.c 
b/tools/testing/selftests/net/csum.c
index b9f3fc3c3426..28f8241b8567 100644
--- a/tools/testing/selftests/net/csum.c
+++ b/tools/testing/selftests/net/csum.c
@@ -58,9 +58,6 @@
  * different seed for each run (and logs this for reproducibility). It
  * is advised to enable this for extra coverage in continuous testing.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/net/gro.c 
b/tools/testing/selftests/net/gro.c
index 6038b96ecee8..dd370c88af1e 100644
--- a/tools/testing/selftests/net/gro.c
+++ 

[PATCH v4 34/66] selftests/mqueue: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/mqueue/mq_perf_tests.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/mqueue/mq_perf_tests.c 
b/tools/testing/selftests/mqueue/mq_perf_tests.c
index fb898850867c..43630ee0b63d 100644
--- a/tools/testing/selftests/mqueue/mq_perf_tests.c
+++ b/tools/testing/selftests/mqueue/mq_perf_tests.c
@@ -20,7 +20,6 @@
  *   performance.
  *
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 33/66] selftests/move_mount_set_group: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 .../selftests/move_mount_set_group/move_mount_set_group_test.c   | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c 
b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
index bcf51d785a37..bd975670f61d 100644
--- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
+++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 32/66] selftests/mount_setattr: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/mount_setattr/mount_setattr_test.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/mount_setattr/mount_setattr_test.c 
b/tools/testing/selftests/mount_setattr/mount_setattr_test.c
index c6a8c732b802..d894417134b6 100644
--- a/tools/testing/selftests/mount_setattr/mount_setattr_test.c
+++ b/tools/testing/selftests/mount_setattr/mount_setattr_test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 31/66] selftests/mount: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/mount/nosymfollow-test.c  | 1 -
 tools/testing/selftests/mount/unprivileged-remount-test.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/mount/nosymfollow-test.c 
b/tools/testing/selftests/mount/nosymfollow-test.c
index 650d6d80a1d2..285453750ffc 100644
--- a/tools/testing/selftests/mount/nosymfollow-test.c
+++ b/tools/testing/selftests/mount/nosymfollow-test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mount/unprivileged-remount-test.c 
b/tools/testing/selftests/mount/unprivileged-remount-test.c
index d2917054fe3a..daffcf5c2f6d 100644
--- a/tools/testing/selftests/mount/unprivileged-remount-test.c
+++ b/tools/testing/selftests/mount/unprivileged-remount-test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 30/66] selftests/mm: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/mm/cow.c   | 1 -
 tools/testing/selftests/mm/gup_longterm.c  | 1 -
 tools/testing/selftests/mm/hugepage-mmap.c | 1 -
 tools/testing/selftests/mm/hugepage-mremap.c   | 2 --
 tools/testing/selftests/mm/hugetlb-madvise.c   | 2 --
 tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 2 --
 tools/testing/selftests/mm/khugepaged.c| 1 -
 tools/testing/selftests/mm/ksm_functional_tests.c  | 1 -
 tools/testing/selftests/mm/madv_populate.c | 1 -
 tools/testing/selftests/mm/map_populate.c  | 2 --
 tools/testing/selftests/mm/mdwe_test.c | 1 -
 tools/testing/selftests/mm/memfd_secret.c  | 2 --
 tools/testing/selftests/mm/mlock2-tests.c  | 1 -
 tools/testing/selftests/mm/mrelease_test.c | 1 -
 tools/testing/selftests/mm/mremap_dontunmap.c  | 1 -
 tools/testing/selftests/mm/mremap_test.c   | 2 --
 tools/testing/selftests/mm/mseal_test.c| 1 -
 tools/testing/selftests/mm/pagemap_ioctl.c | 1 -
 tools/testing/selftests/mm/pkey-helpers.h  | 1 -
 tools/testing/selftests/mm/protection_keys.c   | 1 -
 tools/testing/selftests/mm/seal_elf.c  | 1 -
 tools/testing/selftests/mm/split_huge_page_test.c  | 2 --
 tools/testing/selftests/mm/thuge-gen.c | 2 --
 tools/testing/selftests/mm/uffd-common.h   | 1 -
 24 files changed, 32 deletions(-)

diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index 32c6ccc2a6be..8747ffef200f 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -6,7 +6,6 @@
  *
  * Author(s): David Hildenbrand 
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/gup_longterm.c 
b/tools/testing/selftests/mm/gup_longterm.c
index 9423ad439a61..53c257f6159c 100644
--- a/tools/testing/selftests/mm/gup_longterm.c
+++ b/tools/testing/selftests/mm/gup_longterm.c
@@ -6,7 +6,6 @@
  *
  * Author(s): David Hildenbrand 
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/hugepage-mmap.c 
b/tools/testing/selftests/mm/hugepage-mmap.c
index 267eea2e0e0b..edb46888222f 100644
--- a/tools/testing/selftests/mm/hugepage-mmap.c
+++ b/tools/testing/selftests/mm/hugepage-mmap.c
@@ -16,7 +16,6 @@
  * range.
  * Other architectures, such as ppc64, i386 or x86_64 are not so constrained.
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/hugepage-mremap.c 
b/tools/testing/selftests/mm/hugepage-mremap.c
index c463d1c09c9b..8e22822bb754 100644
--- a/tools/testing/selftests/mm/hugepage-mremap.c
+++ b/tools/testing/selftests/mm/hugepage-mremap.c
@@ -11,8 +11,6 @@
  * To make sure the test triggers pmd sharing and goes through the 'unshare'
  * path in the mremap code use 1GB (1024) or more.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/hugetlb-madvise.c 
b/tools/testing/selftests/mm/hugetlb-madvise.c
index e74107185324..70c40c67bc5d 100644
--- a/tools/testing/selftests/mm/hugetlb-madvise.c
+++ b/tools/testing/selftests/mm/hugetlb-madvise.c
@@ -11,8 +11,6 @@
  * filesystem.  Therefore, a hugetlbfs filesystem must be mounted on some
  * directory.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c 
b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
index ba6cc6f9cabc..6b8b41b4f754 100644
--- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
+++ b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/khugepaged.c 
b/tools/testing/selftests/mm/khugepaged.c
index 829320a519e7..d18bf400dae6 100644
--- a/tools/testing/selftests/mm/khugepaged.c
+++ b/tools/testing/selftests/mm/khugepaged.c
@@ -1,4 +1,3 @@
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c 
b/tools/testing/selftests/mm/ksm_functional_tests.c
index 37de82da9be7..b0af40ddb0fb 100644
--- a/tools/testing/selftests/mm/ksm_functional_tests.c
+++ b/tools/testing/selftests/mm/ksm_functional_tests.c
@@ -6,7 +6,6 @@
  *
  * Author(s): David Hildenbrand 
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/madv_populate.c 
b/tools/testing/selftests/mm/madv_populate.c
index ef7d911da13e..f2c8223ff3d4 100644
--- a/tools/testing/selftests/mm/madv_populate.c
+++ b/tools/testing/selftests/mm/madv_populate.c
@@ -6,7 +6,6 @@
  *
  * Author(s): David Hildenbrand 
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/mm/map_populate.c 

[PATCH v4 29/66] selftests/mincore: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/mincore/mincore_selftest.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/testing/selftests/mincore/mincore_selftest.c 
b/tools/testing/selftests/mincore/mincore_selftest.c
index e949a43a6145..e12398366523 100644
--- a/tools/testing/selftests/mincore/mincore_selftest.c
+++ b/tools/testing/selftests/mincore/mincore_selftest.c
@@ -4,9 +4,6 @@
  *
  * Copyright (C) 2020 Collabora, Ltd.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 28/66] selftests/memfd: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/memfd/common.c | 1 -
 tools/testing/selftests/memfd/fuse_test.c  | 2 --
 tools/testing/selftests/memfd/memfd_test.c | 1 -
 3 files changed, 4 deletions(-)

diff --git a/tools/testing/selftests/memfd/common.c 
b/tools/testing/selftests/memfd/common.c
index 8eb3d75f6e60..879d4f4c66fa 100644
--- a/tools/testing/selftests/memfd/common.c
+++ b/tools/testing/selftests/memfd/common.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #define __EXPORTED_HEADERS__
 
 #include 
diff --git a/tools/testing/selftests/memfd/fuse_test.c 
b/tools/testing/selftests/memfd/fuse_test.c
index dbc171a3806d..e35c6909f0bb 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -12,8 +12,6 @@
  * the read() syscall with our memory-mapped memfd object as receive buffer to
  * force the kernel to write into our memfd object.
  */
-
-#define _GNU_SOURCE
 #define __EXPORTED_HEADERS__
 
 #include 
diff --git a/tools/testing/selftests/memfd/memfd_test.c 
b/tools/testing/selftests/memfd/memfd_test.c
index 95af2d78fd31..ee019b57bb98 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #define __EXPORTED_HEADERS__
 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 27/66] selftests/membarrier: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/membarrier/membarrier_test_impl.h| 1 -
 .../testing/selftests/membarrier/membarrier_test_multi_thread.c  | 1 -
 .../testing/selftests/membarrier/membarrier_test_single_thread.c | 1 -
 3 files changed, 3 deletions(-)

diff --git a/tools/testing/selftests/membarrier/membarrier_test_impl.h 
b/tools/testing/selftests/membarrier/membarrier_test_impl.h
index af89855adb7b..a8a60b6271a5 100644
--- a/tools/testing/selftests/membarrier/membarrier_test_impl.h
+++ b/tools/testing/selftests/membarrier/membarrier_test_impl.h
@@ -1,5 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c 
b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
index 4e14dba81234..c00f380b2757 100644
--- a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
+++ b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/membarrier/membarrier_test_single_thread.c 
b/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
index fa3f1d6c37a0..c399fbad8efd 100644
--- a/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
+++ b/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 26/66] selftests/lsm: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/lsm/common.c | 2 --
 tools/testing/selftests/lsm/lsm_get_self_attr_test.c | 2 --
 tools/testing/selftests/lsm/lsm_list_modules_test.c  | 2 --
 tools/testing/selftests/lsm/lsm_set_self_attr_test.c | 2 --
 4 files changed, 8 deletions(-)

diff --git a/tools/testing/selftests/lsm/common.c 
b/tools/testing/selftests/lsm/common.c
index 9ad258912646..1b18aac570f1 100644
--- a/tools/testing/selftests/lsm/common.c
+++ b/tools/testing/selftests/lsm/common.c
@@ -4,8 +4,6 @@
  *
  * Copyright © 2023 Casey Schaufler 
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/lsm/lsm_get_self_attr_test.c 
b/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
index df215e4aa63f..7465bde3f922 100644
--- a/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
+++ b/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
@@ -5,8 +5,6 @@
  *
  * Copyright © 2022 Casey Schaufler 
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/lsm/lsm_list_modules_test.c 
b/tools/testing/selftests/lsm/lsm_list_modules_test.c
index 06d24d4679a6..a6b44e25c21f 100644
--- a/tools/testing/selftests/lsm/lsm_list_modules_test.c
+++ b/tools/testing/selftests/lsm/lsm_list_modules_test.c
@@ -5,8 +5,6 @@
  *
  * Copyright © 2022 Casey Schaufler 
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/lsm/lsm_set_self_attr_test.c 
b/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
index 66dec47e3ca3..110c6a07e74c 100644
--- a/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
+++ b/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
@@ -5,8 +5,6 @@
  *
  * Copyright © 2022 Casey Schaufler 
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 25/66] selftests/landlock: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/landlock/base_test.c   | 2 --
 tools/testing/selftests/landlock/fs_test.c | 2 --
 tools/testing/selftests/landlock/net_test.c| 2 --
 tools/testing/selftests/landlock/ptrace_test.c | 2 --
 4 files changed, 8 deletions(-)

diff --git a/tools/testing/selftests/landlock/base_test.c 
b/tools/testing/selftests/landlock/base_test.c
index 3c1e9f35b531..c86e6f87b398 100644
--- a/tools/testing/selftests/landlock/base_test.c
+++ b/tools/testing/selftests/landlock/base_test.c
@@ -5,8 +5,6 @@
  * Copyright © 2017-2020 Mickaël Salaün 
  * Copyright © 2019-2020 ANSSI
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/landlock/fs_test.c 
b/tools/testing/selftests/landlock/fs_test.c
index 6b5a9ff88c3d..eec0d9a44d50 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -6,8 +6,6 @@
  * Copyright © 2020 ANSSI
  * Copyright © 2020-2022 Microsoft Corporation
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/landlock/net_test.c 
b/tools/testing/selftests/landlock/net_test.c
index f21cfbbc3638..eed040adcbac 100644
--- a/tools/testing/selftests/landlock/net_test.c
+++ b/tools/testing/selftests/landlock/net_test.c
@@ -5,8 +5,6 @@
  * Copyright © 2022-2023 Huawei Tech. Co., Ltd.
  * Copyright © 2023 Microsoft Corporation
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/landlock/ptrace_test.c 
b/tools/testing/selftests/landlock/ptrace_test.c
index a19db4d0b3bd..c831e6d03b02 100644
--- a/tools/testing/selftests/landlock/ptrace_test.c
+++ b/tools/testing/selftests/landlock/ptrace_test.c
@@ -5,8 +5,6 @@
  * Copyright © 2017-2020 Mickaël Salaün 
  * Copyright © 2019-2020 ANSSI
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 24/66] selftests/kcmp: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/kcmp/kcmp_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/kcmp/kcmp_test.c 
b/tools/testing/selftests/kcmp/kcmp_test.c
index d7a8e321bb16..f0e356139e1f 100644
--- a/tools/testing/selftests/kcmp/kcmp_test.c
+++ b/tools/testing/selftests/kcmp/kcmp_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 23/66] selftests/ipc: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/ipc/msgque.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/ipc/msgque.c 
b/tools/testing/selftests/ipc/msgque.c
index c75ea4094870..45aba6aa8e1d 100644
--- a/tools/testing/selftests/ipc/msgque.c
+++ b/tools/testing/selftests/ipc/msgque.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 22/66] selftests/iommu: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/iommu/Makefile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/iommu/Makefile 
b/tools/testing/selftests/iommu/Makefile
index 32c5fdfd0eef..fd6477911f24 100644
--- a/tools/testing/selftests/iommu/Makefile
+++ b/tools/testing/selftests/iommu/Makefile
@@ -2,8 +2,6 @@
 CFLAGS += -Wall -O2 -Wno-unused-function
 CFLAGS += $(KHDR_INCLUDES)
 
-CFLAGS += -D_GNU_SOURCE
-
 TEST_GEN_PROGS :=
 TEST_GEN_PROGS += iommufd
 TEST_GEN_PROGS += iommufd_fail_nth
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 21/66] selftests/intel_pstate: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/intel_pstate/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/intel_pstate/Makefile 
b/tools/testing/selftests/intel_pstate/Makefile
index 05d66ef50c97..f45372cb00fe 100644
--- a/tools/testing/selftests/intel_pstate/Makefile
+++ b/tools/testing/selftests/intel_pstate/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE
+CFLAGS := $(CFLAGS) -Wall
 LDLIBS += -lm
 
 ARCH ?= $(shell uname -m 2>/dev/null || echo not)
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 20/66] selftests/futex: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/futex/functional/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/futex/functional/Makefile 
b/tools/testing/selftests/futex/functional/Makefile
index a392d0917b4e..f79f9bac7918 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
-CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) 
$(KHDR_INCLUDES)
+CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES)
 LDLIBS := -lpthread -lrt
 
 LOCAL_HDRS := \
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 19/66] selftests/futex: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/futex/functional/futex_requeue_pi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/futex_requeue_pi.c 
b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
index 7f3ca5c78df1..8e41f9fe784c 100644
--- a/tools/testing/selftests/futex/functional/futex_requeue_pi.c
+++ b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
@@ -16,9 +16,6 @@
  *  2009-Nov-6: futex test adaptation by Darren Hart 

  *
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 18/66] selftests/fpu: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/fpu/test_fpu.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/fpu/test_fpu.c 
b/tools/testing/selftests/fpu/test_fpu.c
index 200238522a9d..53a7fef839e7 100644
--- a/tools/testing/selftests/fpu/test_fpu.c
+++ b/tools/testing/selftests/fpu/test_fpu.c
@@ -4,8 +4,6 @@
  * module to perform floating point operations in the kernel. The control
  * register value should be independent between kernel and user mode.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 17/66] selftests/firmware: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/firmware/fw_namespace.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/firmware/fw_namespace.c 
b/tools/testing/selftests/firmware/fw_namespace.c
index 04757dc7e546..c16c185753ad 100644
--- a/tools/testing/selftests/firmware/fw_namespace.c
+++ b/tools/testing/selftests/firmware/fw_namespace.c
@@ -2,7 +2,6 @@
 /* Test triggering of loading of firmware from different mount
  * namespaces. Expect firmware to be always loaded from the mount
  * namespace of PID 1. */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 16/66] selftests/filesystems: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/filesystems/binderfs/binderfs_test.c   | 2 --
 tools/testing/selftests/filesystems/devpts_pts.c   | 1 -
 tools/testing/selftests/filesystems/dnotify_test.c | 1 -
 tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c  | 2 --
 tools/testing/selftests/filesystems/eventfd/eventfd_test.c | 2 --
 tools/testing/selftests/filesystems/fat/rename_exchange.c  | 2 --
 tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c| 2 --
 tools/testing/selftests/filesystems/statmount/statmount_test.c | 3 ---
 8 files changed, 15 deletions(-)

diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c 
b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
index 5f362c0fd890..fca693db1b09 100644
--- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
+++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/filesystems/devpts_pts.c 
b/tools/testing/selftests/filesystems/devpts_pts.c
index b1fc9b916ace..73766447eeb0 100644
--- a/tools/testing/selftests/filesystems/devpts_pts.c
+++ b/tools/testing/selftests/filesystems/devpts_pts.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/filesystems/dnotify_test.c 
b/tools/testing/selftests/filesystems/dnotify_test.c
index c0a9b2d3302d..05367a70b963 100644
--- a/tools/testing/selftests/filesystems/dnotify_test.c
+++ b/tools/testing/selftests/filesystems/dnotify_test.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE/* needed to get the defines */
 #include  /* in glibc 2.2 this has the needed
   values defined */
 #include 
diff --git a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c 
b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
index 65ede506305c..9bc2ddad7e92 100644
--- a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
+++ b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c 
b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
index f142a137526c..17935f42fbc9 100644
--- a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
+++ b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/filesystems/fat/rename_exchange.c 
b/tools/testing/selftests/filesystems/fat/rename_exchange.c
index e488ad354fce..56cf3ad8640d 100644
--- a/tools/testing/selftests/filesystems/fat/rename_exchange.c
+++ b/tools/testing/selftests/filesystems/fat/rename_exchange.c
@@ -6,8 +6,6 @@
  * Copyright 2022 Red Hat Inc.
  * Author: Javier Martinez Canillas 
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c 
b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
index 759f86e7d263..b58a80bde95a 100644
--- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
+++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test.c 
b/tools/testing/selftests/filesystems/statmount/statmount_test.c
index e6d7c4f1c85b..c8944effb780 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
@@ -1,7 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 15/66] selftests/filelock: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/filelock/ofdlocks.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/filelock/ofdlocks.c 
b/tools/testing/selftests/filelock/ofdlocks.c
index a55b79810ab2..301c63ddcceb 100644
--- a/tools/testing/selftests/filelock/ofdlocks.c
+++ b/tools/testing/selftests/filelock/ofdlocks.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 14/66] selftests/fchmodat2: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/fchmodat2/fchmodat2_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/fchmodat2/fchmodat2_test.c 
b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
index e0319417124d..6b411859c2cd 100644
--- a/tools/testing/selftests/fchmodat2/fchmodat2_test.c
+++ b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 13/66] selftests/exec: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/exec/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/exec/Makefile 
b/tools/testing/selftests/exec/Makefile
index fb4472ddffd8..c5bdb653422b 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS = -Wall
 CFLAGS += -Wno-nonnull
-CFLAGS += -D_GNU_SOURCE
 
 TEST_PROGS := binfmt_script.py
 TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 
load_address_16777216 non-regular
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 12/66] selftests/drivers: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/drivers/dma-buf/udmabuf.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c 
b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
index c812080e304e..7c8dbab8ac44 100644
--- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c
+++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
 #define __EXPORTED_HEADERS__
 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 11/66] selftests/damon: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: SeongJae Park 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c | 2 --
 .../damon/debugfs_target_ids_read_before_terminate_race.c   | 1 -
 2 files changed, 3 deletions(-)

diff --git a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c 
b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
index 0cc2eef7d142..3f0dd30f61ef 100644
--- a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
+++ b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
@@ -3,8 +3,6 @@
  * Author: SeongJae Park 
  */
 
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git 
a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c 
b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
index b06f52a8ce2d..611396076420 100644
--- 
a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
+++ 
b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
@@ -2,7 +2,6 @@
 /*
  * Author: SeongJae Park 
  */
-#define _GNU_SOURCE
 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 10/66] selftests/core: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/core/close_range_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/core/close_range_test.c 
b/tools/testing/selftests/core/close_range_test.c
index c59e4adb905d..1c2902bcc913 100644
--- a/tools/testing/selftests/core/close_range_test.c
+++ b/tools/testing/selftests/core/close_range_test.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 09/66] selftests/clone3: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/clone3/clone3.c| 2 --
 tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c | 2 --
 tools/testing/selftests/clone3/clone3_clear_sighand.c  | 2 --
 tools/testing/selftests/clone3/clone3_selftests.h  | 1 -
 tools/testing/selftests/clone3/clone3_set_tid.c| 2 --
 5 files changed, 9 deletions(-)

diff --git a/tools/testing/selftests/clone3/clone3.c 
b/tools/testing/selftests/clone3/clone3.c
index e61f07973ce5..ce2c149dab46 100644
--- a/tools/testing/selftests/clone3/clone3.c
+++ b/tools/testing/selftests/clone3/clone3.c
@@ -1,8 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
 /* Based on Christian Brauner's clone3() example */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c 
b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
index 31b56d625655..bb99ea20f7d5 100644
--- a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
+++ b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
@@ -7,8 +7,6 @@
  */
 
 /* capabilities related code based on selftests/bpf/test_verifier.c */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/clone3/clone3_clear_sighand.c 
b/tools/testing/selftests/clone3/clone3_clear_sighand.c
index ce0426786828..8ee24da7aea8 100644
--- a/tools/testing/selftests/clone3/clone3_clear_sighand.c
+++ b/tools/testing/selftests/clone3/clone3_clear_sighand.c
@@ -1,6 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/clone3/clone3_selftests.h 
b/tools/testing/selftests/clone3/clone3_selftests.h
index 3d2663fe50ba..172e19d5515f 100644
--- a/tools/testing/selftests/clone3/clone3_selftests.h
+++ b/tools/testing/selftests/clone3/clone3_selftests.h
@@ -3,7 +3,6 @@
 #ifndef _CLONE3_SELFTESTS_H
 #define _CLONE3_SELFTESTS_H
 
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/clone3/clone3_set_tid.c 
b/tools/testing/selftests/clone3/clone3_set_tid.c
index bfb0da2b4fdd..a6df528341bb 100644
--- a/tools/testing/selftests/clone3/clone3_set_tid.c
+++ b/tools/testing/selftests/clone3/clone3_set_tid.c
@@ -5,8 +5,6 @@
  * These tests are assuming to be running in the host's
  * PID namespace.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 08/66] selftests/cgroup: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/cgroup/cgroup_util.c| 3 ---
 tools/testing/selftests/cgroup/test_core.c  | 2 --
 tools/testing/selftests/cgroup/test_cpu.c   | 2 --
 tools/testing/selftests/cgroup/test_hugetlb_memcg.c | 2 --
 tools/testing/selftests/cgroup/test_kmem.c  | 2 --
 tools/testing/selftests/cgroup/test_memcontrol.c| 2 --
 tools/testing/selftests/cgroup/test_zswap.c | 2 --
 7 files changed, 15 deletions(-)

diff --git a/tools/testing/selftests/cgroup/cgroup_util.c 
b/tools/testing/selftests/cgroup/cgroup_util.c
index 432db923bced..ce16a50ecff8 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -1,7 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/cgroup/test_core.c 
b/tools/testing/selftests/cgroup/test_core.c
index a5672a91d273..de8baad46022 100644
--- a/tools/testing/selftests/cgroup/test_core.c
+++ b/tools/testing/selftests/cgroup/test_core.c
@@ -1,6 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/cgroup/test_cpu.c 
b/tools/testing/selftests/cgroup/test_cpu.c
index dad2ed82f3ef..5a4a314f6af7 100644
--- a/tools/testing/selftests/cgroup/test_cpu.c
+++ b/tools/testing/selftests/cgroup/test_cpu.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c 
b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c
index 856f9508ea56..80d05d50a42d 100644
--- a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c
+++ b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/cgroup/test_kmem.c 
b/tools/testing/selftests/cgroup/test_kmem.c
index 96693d8772be..2e453ac50c0d 100644
--- a/tools/testing/selftests/cgroup/test_kmem.c
+++ b/tools/testing/selftests/cgroup/test_kmem.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c 
b/tools/testing/selftests/cgroup/test_memcontrol.c
index 41ae8047b889..c871630d62a3 100644
--- a/tools/testing/selftests/cgroup/test_memcontrol.c
+++ b/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -1,6 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/cgroup/test_zswap.c 
b/tools/testing/selftests/cgroup/test_zswap.c
index 190096017f80..cfaa94e0a175 100644
--- a/tools/testing/selftests/cgroup/test_zswap.c
+++ b/tools/testing/selftests/cgroup/test_zswap.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 07/66] selftests/capabilities: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/capabilities/test_execve.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/capabilities/test_execve.c 
b/tools/testing/selftests/capabilities/test_execve.c
index 47bad7ddc5bc..7c37ae2407c6 100644
--- a/tools/testing/selftests/capabilities/test_execve.c
+++ b/tools/testing/selftests/capabilities/test_execve.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 06/66] selftests/cachestat: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/cachestat/test_cachestat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/cachestat/test_cachestat.c 
b/tools/testing/selftests/cachestat/test_cachestat.c
index b171fd53b004..c1a6ce7b0912 100644
--- a/tools/testing/selftests/cachestat/test_cachestat.c
+++ b/tools/testing/selftests/cachestat/test_cachestat.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 05/66] selftests/breakpoints: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/breakpoints/breakpoint_test_arm64.c   | 3 ---
 tools/testing/selftests/breakpoints/step_after_suspend_test.c | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c 
b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
index e7041816085a..e5a95187ac12 100644
--- a/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
+++ b/tools/testing/selftests/breakpoints/breakpoint_test_arm64.c
@@ -7,9 +7,6 @@
  * Code modified by Pratyush Anand 
  * for testing different byte select for each access size.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/breakpoints/step_after_suspend_test.c 
b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
index b8703c499d28..695c10893fa4 100644
--- a/tools/testing/selftests/breakpoints/step_after_suspend_test.c
+++ b/tools/testing/selftests/breakpoints/step_after_suspend_test.c
@@ -2,9 +2,6 @@
 /*
  * Copyright (C) 2016 Google, Inc.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 04/66] selftests/bpf: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/bpf/bench.c| 1 -
 tools/testing/selftests/bpf/benchs/bench_trigger.c | 1 -
 tools/testing/selftests/bpf/cgroup_helpers.c   | 1 -
 tools/testing/selftests/bpf/map_tests/task_storage_map.c   | 1 -
 tools/testing/selftests/bpf/network_helpers.c  | 2 --
 tools/testing/selftests/bpf/prog_tests/bind_perm.c | 1 -
 tools/testing/selftests/bpf/prog_tests/bpf_cookie.c| 1 -
 tools/testing/selftests/bpf/prog_tests/bpf_iter_setsockopt.c   | 1 -
 tools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c   | 1 -
 tools/testing/selftests/bpf/prog_tests/btf_endian.c| 1 -
 tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c   | 2 --
 tools/testing/selftests/bpf/prog_tests/cgrp_kfunc.c| 2 --
 tools/testing/selftests/bpf/prog_tests/cgrp_local_storage.c| 2 --
 tools/testing/selftests/bpf/prog_tests/cls_redirect.c  | 3 ---
 tools/testing/selftests/bpf/prog_tests/connect_ping.c  | 2 --
 tools/testing/selftests/bpf/prog_tests/core_retro.c| 1 -
 tools/testing/selftests/bpf/prog_tests/d_path.c| 1 -
 tools/testing/selftests/bpf/prog_tests/deny_namespace.c| 1 -
 tools/testing/selftests/bpf/prog_tests/fexit_sleep.c   | 1 -
 .../testing/selftests/bpf/prog_tests/flow_dissector_reattach.c | 2 --
 tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c  | 1 -
 tools/testing/selftests/bpf/prog_tests/htab_reuse.c| 1 -
 tools/testing/selftests/bpf/prog_tests/htab_update.c   | 1 -
 tools/testing/selftests/bpf/prog_tests/map_in_map.c| 1 -
 tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c   | 2 --
 tools/testing/selftests/bpf/prog_tests/perf_branches.c | 1 -
 tools/testing/selftests/bpf/prog_tests/perf_buffer.c   | 1 -
 tools/testing/selftests/bpf/prog_tests/perf_event_stackmap.c   | 1 -
 tools/testing/selftests/bpf/prog_tests/perf_link.c | 1 -
 tools/testing/selftests/bpf/prog_tests/perf_skip.c | 2 --
 tools/testing/selftests/bpf/prog_tests/preempted_bpf_ma_op.c   | 1 -
 tools/testing/selftests/bpf/prog_tests/rcu_read_lock.c | 2 --
 tools/testing/selftests/bpf/prog_tests/reg_bounds.c| 2 --
 tools/testing/selftests/bpf/prog_tests/ringbuf.c   | 1 -
 tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c | 1 -
 tools/testing/selftests/bpf/prog_tests/setget_sockopt.c| 2 --
 tools/testing/selftests/bpf/prog_tests/sk_assign.c | 2 --
 tools/testing/selftests/bpf/prog_tests/sk_lookup.c | 2 --
 tools/testing/selftests/bpf/prog_tests/sock_fields.c   | 2 --
 tools/testing/selftests/bpf/prog_tests/task_kfunc.c| 2 --
 tools/testing/selftests/bpf/prog_tests/task_local_storage.c| 2 --
 tools/testing/selftests/bpf/prog_tests/task_pt_regs.c  | 1 -
 tools/testing/selftests/bpf/prog_tests/tcp_custom_syncookie.c  | 2 --
 tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c   | 2 --
 tools/testing/selftests/bpf/prog_tests/test_bpf_ma.c   | 1 -
 .../testing/selftests/bpf/prog_tests/test_bpf_syscall_macro.c  | 1 -
 tools/testing/selftests/bpf/prog_tests/test_bpffs.c| 1 -
 tools/testing/selftests/bpf/prog_tests/test_overhead.c | 1 -
 tools/testing/selftests/bpf/prog_tests/token.c | 1 -
 tools/testing/selftests/bpf/prog_tests/trace_ext.c | 2 --
 tools/testing/selftests/bpf/prog_tests/trampoline_count.c  | 1 -
 tools/testing/selftests/bpf/prog_tests/user_ringbuf.c  | 2 --
 tools/testing/selftests/bpf/prog_tests/xdp_bonding.c   | 2 --
 tools/testing/selftests/bpf/prog_tests/xdp_synproxy.c  | 2 --
 tools/testing/selftests/bpf/test_flow_dissector.c  | 3 ---
 tools/testing/selftests/bpf/test_lru_map.c | 1 -
 tools/testing/selftests/bpf/test_progs.c   | 1 -
 tools/testing/selftests/bpf/test_sock_addr.c   | 3 ---
 tools/testing/selftests/bpf/test_tcpnotify_user.c  | 1 -
 tools/testing/selftests/bpf/veristat.c | 1 -
 tools/testing/selftests/bpf/xskxceiver.c   | 2 --
 61 files changed, 90 deletions(-)

diff --git a/tools/testing/selftests/bpf/bench.c 
b/tools/testing/selftests/bpf/bench.c
index 627b74ae041b..ab06bd67a22c 100644
--- a/tools/testing/selftests/bpf/bench.c
+++ b/tools/testing/selftests/bpf/bench.c
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright (c) 2020 Facebook */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/bpf/benchs/bench_trigger.c 
b/tools/testing/selftests/bpf/benchs/bench_trigger.c
index 4b05539f167d..dc84469cbfa6 100644
--- 

[PATCH v4 03/66] selftests/arm64: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Edward Liaw
-D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/arm64/signal/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/arm64/signal/Makefile 
b/tools/testing/selftests/arm64/signal/Makefile
index 8f5febaf1a9a..37c8207b99cf 100644
--- a/tools/testing/selftests/arm64/signal/Makefile
+++ b/tools/testing/selftests/arm64/signal/Makefile
@@ -2,7 +2,7 @@
 # Copyright (C) 2019 ARM Limited
 
 # Additional include paths needed by kselftest.h and local headers
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
+CFLAGS += -std=gnu99 -I.
 
 SRCS := $(filter-out testcases/testcases.c,$(wildcard testcases/*.c))
 PROGS := $(patsubst %.c,%,$(SRCS))
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 02/66] selftests/arm64: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/arm64/fp/fp-ptrace.c  | 3 ---
 tools/testing/selftests/arm64/fp/fp-stress.c  | 2 --
 tools/testing/selftests/arm64/fp/vlset.c  | 1 -
 tools/testing/selftests/arm64/mte/check_buffer_fill.c | 3 ---
 tools/testing/selftests/arm64/mte/check_child_memory.c| 3 ---
 tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c | 3 ---
 tools/testing/selftests/arm64/mte/check_ksm_options.c | 3 ---
 tools/testing/selftests/arm64/mte/check_mmap_options.c| 3 ---
 tools/testing/selftests/arm64/mte/check_tags_inclusion.c  | 3 ---
 tools/testing/selftests/arm64/mte/check_user_mem.c| 3 ---
 tools/testing/selftests/arm64/pauth/pac.c | 3 ---
 11 files changed, 30 deletions(-)

diff --git a/tools/testing/selftests/arm64/fp/fp-ptrace.c 
b/tools/testing/selftests/arm64/fp/fp-ptrace.c
index c7ceafe5f471..eb1f14047361 100644
--- a/tools/testing/selftests/arm64/fp/fp-ptrace.c
+++ b/tools/testing/selftests/arm64/fp/fp-ptrace.c
@@ -3,9 +3,6 @@
  * Copyright (C) 2023 ARM Limited.
  * Original author: Mark Brown 
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/fp/fp-stress.c 
b/tools/testing/selftests/arm64/fp/fp-stress.c
index dd31647b00a2..042f736970c2 100644
--- a/tools/testing/selftests/arm64/fp/fp-stress.c
+++ b/tools/testing/selftests/arm64/fp/fp-stress.c
@@ -2,8 +2,6 @@
 /*
  * Copyright (C) 2022 ARM Limited.
  */
-
-#define _GNU_SOURCE
 #define _POSIX_C_SOURCE 199309L
 
 #include 
diff --git a/tools/testing/selftests/arm64/fp/vlset.c 
b/tools/testing/selftests/arm64/fp/vlset.c
index 76912a581a95..e572c0483c3a 100644
--- a/tools/testing/selftests/arm64/fp/vlset.c
+++ b/tools/testing/selftests/arm64/fp/vlset.c
@@ -3,7 +3,6 @@
  * Copyright (C) 2015-2019 ARM Limited.
  * Original author: Dave Martin 
  */
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/mte/check_buffer_fill.c 
b/tools/testing/selftests/arm64/mte/check_buffer_fill.c
index 1dbbbd47dd50..c0d91f0c7a4d 100644
--- a/tools/testing/selftests/arm64/mte/check_buffer_fill.c
+++ b/tools/testing/selftests/arm64/mte/check_buffer_fill.c
@@ -1,8 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2020 ARM Limited
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/mte/check_child_memory.c 
b/tools/testing/selftests/arm64/mte/check_child_memory.c
index 7597fc632cad..ef69abc7c82d 100644
--- a/tools/testing/selftests/arm64/mte/check_child_memory.c
+++ b/tools/testing/selftests/arm64/mte/check_child_memory.c
@@ -1,8 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2020 ARM Limited
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c 
b/tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c
index 325bca0de0f6..aaa5519c6bbd 100644
--- a/tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c
+++ b/tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c
@@ -1,8 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2020 ARM Limited
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/mte/check_ksm_options.c 
b/tools/testing/selftests/arm64/mte/check_ksm_options.c
index 88c74bc46d4f..76357f914125 100644
--- a/tools/testing/selftests/arm64/mte/check_ksm_options.c
+++ b/tools/testing/selftests/arm64/mte/check_ksm_options.c
@@ -1,8 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2020 ARM Limited
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/mte/check_mmap_options.c 
b/tools/testing/selftests/arm64/mte/check_mmap_options.c
index 17694caaff53..66bddc8fe385 100644
--- a/tools/testing/selftests/arm64/mte/check_mmap_options.c
+++ b/tools/testing/selftests/arm64/mte/check_mmap_options.c
@@ -1,8 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2020 ARM Limited
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/mte/check_tags_inclusion.c 
b/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
index 2b1425b92b69..e66d8b8d5bdc 100644
--- a/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
+++ b/tools/testing/selftests/arm64/mte/check_tags_inclusion.c
@@ -1,8 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2020 ARM Limited
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c 
b/tools/testing/selftests/arm64/mte/check_user_mem.c
index f4ae5f87a3b7..220a8795d889 100644
--- a/tools/testing/selftests/arm64/mte/check_user_mem.c
+++ b/tools/testing/selftests/arm64/mte/check_user_mem.c
@@ -1,8 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 // 

[PATCH v4 01/66] selftests: Compile with -D_GNU_SOURCE when including lib.mk

2024-05-09 Thread Edward Liaw
lib.mk will add -D_GNU_SOURCE to CFLAGS by default.  This will make it
unnecessary to add #define _GNU_SOURCE in the source code.

Suggested-by: John Hubbard 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/Makefile | 4 ++--
 tools/testing/selftests/lib.mk   | 5 -
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index f0431e6cb67e..9039f3709aff 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -170,11 +170,11 @@ ifneq ($(KBUILD_OUTPUT),)
   # $(realpath ...) resolves symlinks
   abs_objtree := $(realpath $(abs_objtree))
   BUILD := $(abs_objtree)/kselftest
-  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
+  KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
 else
   BUILD := $(CURDIR)
   abs_srctree := $(shell cd $(top_srcdir) && pwd)
-  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
+  KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
   DEFAULT_INSTALL_HDR_PATH := 1
 endif

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 3023e0e2f58f..e782f4c96aee 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -67,7 +67,7 @@ MAKEFLAGS += --no-print-directory
 endif

 ifeq ($(KHDR_INCLUDES),)
-KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
+KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
 endif

 # In order to use newer items that haven't yet been added to the user's system
@@ -188,6 +188,9 @@ endef
 clean: $(if $(TEST_GEN_MODS_DIR),clean_mods_dir)
$(CLEAN)

+# Build with _GNU_SOURCE by default
+CFLAGS += -D_GNU_SOURCE
+
 # Enables to extend CFLAGS and LDFLAGS from command line, e.g.
 # make USERCFLAGS=-Werror USERLDFLAGS=-static
 CFLAGS += $(USERCFLAGS)
--
2.45.0.118.g7fe29c98d7-goog




[PATCH v4 00/66] Define _GNU_SOURCE for sources using

2024-05-09 Thread Edward Liaw
Centralizes the definition of _GNU_SOURCE into KHDR_INCLUDES and removes
redefinitions of _GNU_SOURCE from source code.

809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
asprintf into kselftest_harness.h, which is a GNU extension and needs
_GNU_SOURCE to either be defined prior to including headers or with the
-D_GNU_SOURCE flag passed to the compiler.

v1: 
https://lore.kernel.org/linux-kselftest/20240430235057.1351993-1-edl...@google.com/
v2: 
https://lore.kernel.org/linux-kselftest/20240507214254.2787305-1-edl...@google.com/
 - Add -D_GNU_SOURCE to KHDR_INCLUDES so that it is in a single
   location.
 - Remove #define _GNU_SOURCE from source code to resolve redefinition
   warnings.
v3: 
https://lore.kernel.org/linux-kselftest/20240509200022.253089-1-edl...@google.com/
 - Rebase onto linux-next 20240508.
 - Split patches by directory.
 - Add -D_GNU_SOURCE directly to CFLAGS in lib.mk.
 - Delete additional _GNU_SOURCE definitions from source code in
   linux-next.
 - Delete additional -D_GNU_SOURCE flags from Makefiles.
v4:
 - Rebase onto linux-next 20240509.
 - Remove Fixes tag from patches that drop _GNU_SOURCE definition.
 - Restore space between comment and includes for selftests/damon.

Edward Liaw (66):
  selftests: Compile with -D_GNU_SOURCE when including lib.mk
  selftests/arm64: Drop define _GNU_SOURCE
  selftests/arm64: Drop duplicate -D_GNU_SOURCE
  selftests/bpf: Drop define _GNU_SOURCE
  selftests/breakpoints: Drop define _GNU_SOURCE
  selftests/cachestat: Drop define _GNU_SOURCE
  selftests/capabilities: Drop define _GNU_SOURCE
  selftests/cgroup: Drop define _GNU_SOURCE
  selftests/clone3: Drop define _GNU_SOURCE
  selftests/core: Drop define _GNU_SOURCE
  selftests/damon: Drop define _GNU_SOURCE
  selftests/drivers: Drop define _GNU_SOURCE
  selftests/exec: Drop duplicate -D_GNU_SOURCE
  selftests/fchmodat2: Drop define _GNU_SOURCE
  selftests/filelock: Drop define _GNU_SOURCE
  selftests/filesystems: Drop define _GNU_SOURCE
  selftests/firmware: Drop define _GNU_SOURCE
  selftests/fpu: Drop define _GNU_SOURCE
  selftests/futex: Drop define _GNU_SOURCE
  selftests/futex: Drop duplicate -D_GNU_SOURCE
  selftests/intel_pstate: Drop duplicate -D_GNU_SOURCE
  selftests/iommu: Drop duplicate -D_GNU_SOURCE
  selftests/ipc: Drop define _GNU_SOURCE
  selftests/kcmp: Drop define _GNU_SOURCE
  selftests/landlock: Drop define _GNU_SOURCE
  selftests/lsm: Drop define _GNU_SOURCE
  selftests/membarrier: Drop define _GNU_SOURCE
  selftests/memfd: Drop define _GNU_SOURCE
  selftests/mincore: Drop define _GNU_SOURCE
  selftests/mm: Drop define _GNU_SOURCE
  selftests/mount: Drop define _GNU_SOURCE
  selftests/mount_setattr: Drop define _GNU_SOURCE
  selftests/move_mount_set_group: Drop define _GNU_SOURCE
  selftests/mqueue: Drop define _GNU_SOURCE
  selftests/net: Drop define _GNU_SOURCE
  selftests/net: Drop duplicate -D_GNU_SOURCE
  selftests/nolibc: Drop define _GNU_SOURCE
  selftests/nsfs: Drop define _GNU_SOURCE
  selftests/openat2: Drop define _GNU_SOURCE
  selftests/perf_events: Drop define _GNU_SOURCE
  selftests/pid_namespace: Drop define _GNU_SOURCE
  selftests/pidfd: Drop define _GNU_SOURCE
  selftests/ptrace: Drop define _GNU_SOURCE
  selftests/powerpc: Drop define _GNU_SOURCE
  selftests/proc: Drop define _GNU_SOURCE
  selftests/proc: Drop duplicate -D_GNU_SOURCE
  selftests/ptp: Drop define _GNU_SOURCE
  selftests/resctrl: Drop duplicate -D_GNU_SOURCE
  selftests/riscv: Drop define _GNU_SOURCE
  selftests/riscv: Drop duplicate -D_GNU_SOURCE
  selftests/rlimits: Drop define _GNU_SOURCE
  selftests/rseq: Drop define _GNU_SOURCE
  selftests/safesetid: Drop define _GNU_SOURCE
  selftests/sched: Drop define _GNU_SOURCE
  selftests/seccomp: Drop define _GNU_SOURCE
  selftests/sigaltstack: Drop define _GNU_SOURCE
  selftests/splice: Drop define _GNU_SOURCE
  selftests/syscall_user_dispatch: Drop define _GNU_SOURCE
  selftests/thermal: Drop define _GNU_SOURCE
  selftests/timens: Drop define _GNU_SOURCE
  selftests/tmpfs: Drop duplicate -D_GNU_SOURCE
  selftests/uevent: Drop define _GNU_SOURCE
  selftests/user_events: Drop define _GNU_SOURCE
  selftests/vDSO: Drop define _GNU_SOURCE
  selftests/wireguard: Drop define _GNU_SOURCE
  selftests/x86: Drop define _GNU_SOURCE

 tools/testing/selftests/Makefile | 4 ++--
 tools/testing/selftests/arm64/fp/fp-ptrace.c | 3 ---
 tools/testing/selftests/arm64/fp/fp-stress.c | 2 --
 tools/testing/selftests/arm64/fp/vlset.c | 1 -
 tools/testing/selftests/arm64/mte/check_buffer_fill.c| 3 ---
 tools/testing/selftests/arm64/mte/check_child_memory.c   | 3 ---
 tools/testing/selftests/arm64/mte/check_gcr_el1_cswitch.c| 3 ---
 tools/testing/selftests/arm64/mte/check_ksm_options.c| 3 ---
 tools/testing/selftests/arm64/mte/check_mmap_options.c   | 3 ---
 tools/testing/selftests/arm64/mte/check_tags_inclusion.c | 3 ---
 too

[PATCH net-next] selftests: net: local_termination: annotate the expected failures

2024-05-09 Thread Jakub Kicinski
Vladimir said when adding this test:

  The bridge driver fares particularly badly [...] mainly because
  it does not implement IFF_UNICAST_FLT.

See commit 90b9566aa5cd ("selftests: forwarding: add a test for
local_termination.sh").

We don't want to hide the known gaps, but having a test which
always fails prevents us from catching regressions. Report
the cases we know may fail as XFAIL.

Signed-off-by: Jakub Kicinski 
---
CC: vladimir.olt...@nxp.com
CC: sh...@kernel.org
CC: pe...@nvidia.com
CC: liuhang...@gmail.com
CC: bpoir...@nvidia.com
CC: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/net/forwarding/lib.sh |  9 
 .../net/forwarding/local_termination.sh   | 21 ++-
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh 
b/tools/testing/selftests/net/forwarding/lib.sh
index 3353a1745946..4fe28ab5d8b9 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -605,6 +605,15 @@ log_test_xfail()
RET=$ksft_xfail retmsg= log_test "$@"
 }
 
+log_test_xfail()
+{
+   local test_name=$1
+   local opt_str=$2
+
+   printf "TEST: %-60s  [XFAIL]\n" "$test_name $opt_str"
+   return 0
+}
+
 log_info()
 {
local msg=$1
diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh 
b/tools/testing/selftests/net/forwarding/local_termination.sh
index c5b0cbc85b3e..4bba9c78db3e 100755
--- a/tools/testing/selftests/net/forwarding/local_termination.sh
+++ b/tools/testing/selftests/net/forwarding/local_termination.sh
@@ -73,6 +73,10 @@ check_rcv()
local pattern=$3
local should_receive=$4
local should_fail=
+   local xfail_sw=$5
+
+   local kind=$(ip -j -d link show dev $if_name |
+jq -r '.[].linkinfo.info_kind')
 
[ $should_receive = true ] && should_fail=0 || should_fail=1
RET=0
@@ -81,7 +85,14 @@ check_rcv()
 
check_err_fail "$should_fail" "$?" "reception"
 
-   log_test "$if_name: $type"
+   # If not a SW interface, ignore the XFAIL allowance
+   [ "$kind" != veth ] && [ "$kind" != bridge ] && xfail_sw=
+
+   if [ $RET -ne 0 ] && [ "$xfail_sw" == true ]; then
+   log_test_xfail "$if_name: $type"
+   else
+   log_test "$if_name: $type"
+   fi
 }
 
 mc_route_prepare()
@@ -157,7 +168,7 @@ run_test()
 
check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \
"$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \
-   false
+   false true
 
check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, promisc" \
"$smac > $UNKNOWN_UC_ADDR2, ethertype IPv4 (0x0800)" \
@@ -165,7 +176,7 @@ run_test()
 
check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, allmulti" \
"$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \
-   false
+   false true
 
check_rcv $rcv_if_name "Multicast IPv4 to joined group" \
"$smac > $JOINED_MACV4_MC_ADDR, ethertype IPv4 (0x0800)" \
@@ -173,7 +184,7 @@ run_test()
 
check_rcv $rcv_if_name "Multicast IPv4 to unknown group" \
"$smac > $UNKNOWN_MACV4_MC_ADDR1, ethertype IPv4 (0x0800)" \
-   false
+   false true
 
check_rcv $rcv_if_name "Multicast IPv4 to unknown group, promisc" \
"$smac > $UNKNOWN_MACV4_MC_ADDR2, ethertype IPv4 (0x0800)" \
@@ -189,7 +200,7 @@ run_test()
 
check_rcv $rcv_if_name "Multicast IPv6 to unknown group" \
"$smac > $UNKNOWN_MACV6_MC_ADDR1, ethertype IPv6 (0x86dd)" \
-   false
+   false true
 
check_rcv $rcv_if_name "Multicast IPv6 to unknown group, promisc" \
"$smac > $UNKNOWN_MACV6_MC_ADDR2, ethertype IPv6 (0x86dd)" \
-- 
2.45.0




Re: [PATCH v3 04/29] riscv: zicfilp / zicfiss in dt-bindings (extensions.yaml)

2024-05-09 Thread Deepak Gupta

On Thu, May 09, 2024 at 09:32:49PM +0100, Conor Dooley wrote:

On Thu, May 09, 2024 at 11:46:26AM -0700, Deepak Gupta wrote:

On Thu, May 09, 2024 at 07:14:26PM +0100, Conor Dooley wrote:
> On Tue, Apr 16, 2024 at 08:44:16AM -0700, Deepak Gupta wrote:
> > On Mon, Apr 15, 2024 at 02:41:05PM -0500, Rob Herring wrote:
> > > On Wed, Apr 10, 2024 at 02:37:21PM -0700, Deepak Gupta wrote:
> > > > On Wed, Apr 10, 2024 at 4:58 AM Rob Herring  wrote:
> > > > >
> > > > > On Wed, Apr 03, 2024 at 04:34:52PM -0700, Deepak Gupta wrote:
> > > > > > Make an entry for cfi extensions in extensions.yaml.
> > > > > >
> > > > > > Signed-off-by: Deepak Gupta 
> > > > > > ---
> > > > > >  .../devicetree/bindings/riscv/extensions.yaml  | 10 
++
> > > > > >  1 file changed, 10 insertions(+)
> > > > > >
> > > > > > diff --git 
a/Documentation/devicetree/bindings/riscv/extensions.yaml 
b/Documentation/devicetree/bindings/riscv/extensions.yaml
> > > > > > index 63d81dc895e5..45b87ad6cc1c 100644
> > > > > > --- a/Documentation/devicetree/bindings/riscv/extensions.yaml
> > > > > > +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
> > > > > > @@ -317,6 +317,16 @@ properties:
> > > > > >  The standard Zicboz extension for cache-block zeroing 
as ratified
> > > > > >  in commit 3dd606f ("Create cmobase-v1.0.pdf") of 
riscv-CMOs.
> > > > > >
> > > > > > +- const: zicfilp
> > > > > > +  description:
> > > > > > +The standard Zicfilp extension for enforcing forward 
edge control-flow
> > > > > > +integrity in commit 3a20dc9 of riscv-cfi and is in 
public review.
> > > > >
> > > > > Does in public review mean the commit sha is going to change?
> > > > >
> > > >
> > > > Less likely. Next step after public review is to gather comments from
> > > > public review.
> > > > If something is really pressing and needs to be addressed, then yes
> > > > this will change.
> > > > Else this gets ratified as it is.
> > >
> > > If the commit sha can change, then it is useless. What's the guarantee
> > > someone is going to remember to update it if it changes?
> >
> > Sorry for late reply.
> >
> > I was following existing wordings and patterns for messaging in this file.
> > You would rather have me remove sha and only mention that spec is in public
> > review?
>
> Nope, having a commit sha is desired. None of this is mergeable until at
> least the spec becomes frozen, so the sha can be updated at that point
> to the freeze state - or better yet to the ratified state. Being in
> public review is not sufficient.

Spec is frozen.
As per RVI spec lifecycle, spec freeze is a prior step to public review.
Public review concluded on 25th April
https://lists.riscv.org/g/tech-ss-lp-cfi/message/91

Next step is ratification whenever board meets.


Ah, I did the "silly" thing of looking on the RVI website at extension
status (because I never know the order of things) and these two
extensions were marked on there as being in the inception phase, so I
incorrectly assumed that "public review" came before freeze.
Freeze is the standard that we have been applying so far, but if
ratification is imminent, and nothing has changed in the review period,
then it seems sane to just pick the freeze point for the definition.


Yeah I don't think wiki is that regularly updated.
But take a look at Ratification-Ready list of specs here
https://wiki.riscv.org/display/HOME/RISC-V+Specification+Status



Cheers,
Conor.






Re: [PATCH v3 03/68] selftests: Compile with -D_GNU_SOURCE when including lib.mk

2024-05-09 Thread Edward Liaw
On Thu, May 9, 2024 at 2:25 PM John Hubbard  wrote:
>
> On 5/9/24 12:57 PM, Edward Liaw wrote:
> > lib.mk will add -D_GNU_SOURCE to CFLAGS by default.  This will make it
> > unnecessary to add #define _GNU_SOURCE in the source code.
> >
> > Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
> > Suggested-by: John Hubbard 
> > Signed-off-by: Edward Liaw 
> > ---
> >   tools/testing/selftests/Makefile | 4 ++--
> >   tools/testing/selftests/lib.mk   | 5 -
> >   2 files changed, 6 insertions(+), 3 deletions(-)
> >
>
> Hi Edward,
>
> This looks good, with one small refactoring opportunity remaining, though:
>
> > diff --git a/tools/testing/selftests/Makefile 
> > b/tools/testing/selftests/Makefile
> > index f0431e6cb67e..9039f3709aff 100644
> > --- a/tools/testing/selftests/Makefile
> > +++ b/tools/testing/selftests/Makefile
> > @@ -170,11 +170,11 @@ ifneq ($(KBUILD_OUTPUT),)
> > # $(realpath ...) resolves symlinks
> > abs_objtree := $(realpath $(abs_objtree))
> > BUILD := $(abs_objtree)/kselftest
> > -  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
> > +  KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
> >   else
> > BUILD := $(CURDIR)
> > abs_srctree := $(shell cd $(top_srcdir) && pwd)
> > -  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
> > +  KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
>
> As mentioned in [1] (but there are a lot of patches to manage here, and
> I think it got overlooked), you could factor out the duplicated
> -D_GNU_SOURCE items into a single place:

Hi John,
Here I'm reverting the change I made to the Makefile in patch 1/68,
since -D_GNU_SOURCE is being added directly to CFLAGS now, I didn't
think it was necessary to add it to KHDR_INCLUDES anymore.  I would
have merged the two patches together, but since the first and second
patches from v2 were already merged, I thought I should leave them in
the series.

Thanks,
Edward

>
> [1]
> https://lore.kernel.org/all/ac8c217e-4109-4ca7-a7dd-fc4fc8b0a...@nvidia.com/
>
> thanks,
> --
> John Hubbard
> NVIDIA
>
> > DEFAULT_INSTALL_HDR_PATH := 1
> >   endif
> >
> > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> > index 3023e0e2f58f..e782f4c96aee 100644
> > --- a/tools/testing/selftests/lib.mk
> > +++ b/tools/testing/selftests/lib.mk
> > @@ -67,7 +67,7 @@ MAKEFLAGS += --no-print-directory
> >   endif
> >
> >   ifeq ($(KHDR_INCLUDES),)
> > -KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
> > +KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
> >   endif
> >
> >   # In order to use newer items that haven't yet been added to the user's 
> > system
> > @@ -188,6 +188,9 @@ endef
> >   clean: $(if $(TEST_GEN_MODS_DIR),clean_mods_dir)
> >   $(CLEAN)
> >
> > +# Build with _GNU_SOURCE by default
> > +CFLAGS += -D_GNU_SOURCE
> > +
> >   # Enables to extend CFLAGS and LDFLAGS from command line, e.g.
> >   # make USERCFLAGS=-Werror USERLDFLAGS=-static
> >   CFLAGS += $(USERCFLAGS)
>
>



Re: [PATCH v4 7/9] riscv: vector: adjust minimum Vector requirement to ZVE32X

2024-05-09 Thread Conor Dooley
On Thu, May 09, 2024 at 09:25:25AM +0100, Conor Dooley wrote:
> On Thu, May 09, 2024 at 08:48:09AM +0100, Conor Dooley wrote:
> > On Thu, May 09, 2024 at 02:56:30PM +0800, Andy Chiu wrote:
> > > Hi Conor,
> > > 
> > > Should we check if "v" presents for vector crypto extensions in
> > > riscv_isa_extension_check()? We are not checking this for now. So a
> > > kernel compiled with RISCV_ISA_V still has a problem if its isa-string
> > > includes any of vector crypto ("zvbb, zvkg, etc") but not "v".
> > 
> > 
> > Yeah, one of the things I took away from this discussion is that we need
> > to improve the implementation of both the methods we have at the moment
> > for drivers etc to check if extensions are present and usable.
> > In general, I don't think checks like that are "safe" to do in
> > riscv_isa_extension_check(), because the dependencies may not all have
> > been resolved when we probe an extension (Clement's current Zca etc
> > series improves the situation though by only calling the checks after
> > we probe all extensions).
> > 
> > The simple V cases are all fine though - the DT binding and ACPI rules
> > for compatible strings all mandate that single-letter extensions must
> > come before multi-letter ones. For riscv,isa-extensions we control the
> > probe ordering and probe V before any multi-letter stuff. Additionally,
> > we should make it a requirement for V to be present if things that
> > depend on it are.
> > 
> > That said, is it permitted by the specs to have any of the extensions
> > you mention without the full V extension, but with one of the cut-down
> > variants you mention here? If not, I'd be more interested in figuring
> > out the non-extension dependencies: whether or not the kernel itself
> > supports vector and if the kernel has opted to disable vector due to
> > detecting that harts have mismatching vector lengths.
> > 
> > TL;DR: I think we should add some checks in riscv_isa_extension_check().
> 
> Also, unless this only becomes a problem with this series that adds the
> cut-down forms of vector, I think this is a separate problem to solve
> and I can send some patches for it (along with some other cleanup I'd like
> to do as a result of Eric's comments) and you can just submit the v2 you
> were planning to without it. I can't, off the top of my head, think of
> why this particular series would break the vector crypto stuff though,
> the problems with enabling extensions seem underlying.

Here's something buggy that I chucked together as an idea of what I
meant:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h=riscv-check_vector
Beware, it is entirely untested :)
It's based on both this series and patches 2 & 3 of Charlie's series doing
the T-Head vector stuff. It really needs Clement's extension_check()
rework that I mentioned 2 mails ago to function correctly for any of these
vector subsets. Without Clement's stuff, it'll have "random" behaviour
depending on probe order for riscv,isa and a determinate, but incorrect,
behaviour otherwise.

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH v3 50/68] selftests/resctrl: Drop duplicate -D_GNU_SOURCE

2024-05-09 Thread Reinette Chatre
Hi Edward,

On 5/9/2024 12:58 PM, Edward Liaw wrote:
> -D_GNU_SOURCE can be de-duplicated here, as it is added by lib.mk.
> 
> Reviewed-by: John Hubbard 
> Reviewed-by: Muhammad Usama Anjum 
> Signed-off-by: Edward Liaw 
> ---

Thank you very much.

Acked-by: Reinette Chatre 

Reinette



Re: [PATCH v3 03/68] selftests: Compile with -D_GNU_SOURCE when including lib.mk

2024-05-09 Thread John Hubbard

On 5/9/24 12:57 PM, Edward Liaw wrote:

lib.mk will add -D_GNU_SOURCE to CFLAGS by default.  This will make it
unnecessary to add #define _GNU_SOURCE in the source code.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Suggested-by: John Hubbard 
Signed-off-by: Edward Liaw 
---
  tools/testing/selftests/Makefile | 4 ++--
  tools/testing/selftests/lib.mk   | 5 -
  2 files changed, 6 insertions(+), 3 deletions(-)



Hi Edward,

This looks good, with one small refactoring opportunity remaining, though:


diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index f0431e6cb67e..9039f3709aff 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -170,11 +170,11 @@ ifneq ($(KBUILD_OUTPUT),)
# $(realpath ...) resolves symlinks
abs_objtree := $(realpath $(abs_objtree))
BUILD := $(abs_objtree)/kselftest
-  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
+  KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
  else
BUILD := $(CURDIR)
abs_srctree := $(shell cd $(top_srcdir) && pwd)
-  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
+  KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include


As mentioned in [1] (but there are a lot of patches to manage here, and
I think it got overlooked), you could factor out the duplicated
-D_GNU_SOURCE items into a single place:

[1] 
https://lore.kernel.org/all/ac8c217e-4109-4ca7-a7dd-fc4fc8b0a...@nvidia.com/


thanks,
--
John Hubbard
NVIDIA


DEFAULT_INSTALL_HDR_PATH := 1
  endif
  
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk

index 3023e0e2f58f..e782f4c96aee 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -67,7 +67,7 @@ MAKEFLAGS += --no-print-directory
  endif
  
  ifeq ($(KHDR_INCLUDES),)

-KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
+KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
  endif
  
  # In order to use newer items that haven't yet been added to the user's system

@@ -188,6 +188,9 @@ endef
  clean: $(if $(TEST_GEN_MODS_DIR),clean_mods_dir)
$(CLEAN)
  
+# Build with _GNU_SOURCE by default

+CFLAGS += -D_GNU_SOURCE
+
  # Enables to extend CFLAGS and LDFLAGS from command line, e.g.
  # make USERCFLAGS=-Werror USERLDFLAGS=-static
  CFLAGS += $(USERCFLAGS)






Re: [PATCH v3 13/68] selftests/damon: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
On Thu, May 9, 2024 at 1:31 PM SeongJae Park  wrote:
>
> Hi Edward,
>
> On Thu,  9 May 2024 19:58:05 + Edward Liaw  wrote:
>
> > _GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
> > redefinition warnings.
> >
> > Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
>
> I show Mathieu's comment on this[1].  I have no strong opinion on this, but if
> you conclude to remove or change this line, please apply same change to this
> patch.

Will do, thanks for reviewing.

>
> [1] https://lore.kernel.org/638a7831-493c-4917-9b22-5aa663e9e...@efficios.com
>
> > Signed-off-by: Edward Liaw 
>
> I also added trivial comments that coming from my personal and humble
> preferrence below.  Other than the above and the below comments,
>
> Reviewed-by: SeongJae Park 
>
> > ---
> >  tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c| 3 ---
> >  .../damon/debugfs_target_ids_read_before_terminate_race.c  | 2 --
> >  2 files changed, 5 deletions(-)
> >
> > diff --git a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c 
> > b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
> > index 0cc2eef7d142..7a17a03d555c 100644
> > --- a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
> > +++ b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
> > @@ -2,9 +2,6 @@
> >  /*
> >   * Author: SeongJae Park 
> >   */
> > -
> > -#define _GNU_SOURCE
> > -
> >  #include 
>
> I'd prefer having one empty line between the comment and includes.
>
> >  #include 
> >  #include 
> > diff --git 
> > a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
> >  
> > b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
> > index b06f52a8ce2d..4aeac55ac93e 100644
> > --- 
> > a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
> > +++ 
> > b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
> > @@ -2,8 +2,6 @@
> >  /*
> >   * Author: SeongJae Park 
> >   */
> > -#define _GNU_SOURCE
> > -
> >  #include 
>
> Ditto.
>
> And I realize I also forgot adding one empty line before the above #define
> line.  That's why I'm saying this is just a trivial comment :)

No problem, I will add it back in.

Thanks,
Edward


>
> >  #include 
> >  #include 
> > --
> > 2.45.0.118.g7fe29c98d7-goog
>
>
> Thanks,
> SJ



Re: [PATCH v3 54/68] selftests/rseq: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
On Thu, May 9, 2024 at 1:16 PM Mathieu Desnoyers
 wrote:
>
> On 2024-05-09 15:58, Edward Liaw wrote:
> > _GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
> > redefinition warnings.
> >
> > Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
>
> The patch per se looks fine, except for the "Fixes" tag.
>
> Commit 809216233555 introduces use of asprintf in kselftest_harness.h
> which is used by (all ?) selftests, including the rseq ones. However,
> the rseq selftests each have the #define _GNU_SOURCE, which would have
> been OK without those further changes.
>
> So this patch is more about consolidating where the _GNU_SOURCE is
> defined, which is OK with me, but not so much about "fixing" an
> issue with commit 809216233555.
>
> A "Fix" is something to be backported to stable kernels, and I
> don't think this patch reaches that threshold.
>
> If anything, this patch removes a warning that gets added by
> https://lore.kernel.org/lkml/20240509200022.253089-1-edl...@google.com/T/#mf8438d03de6e2b613da4f86d4f60c5fe1c5f8483
> within the same series.
>
> Arguably, each #define _GNU_SOURCE could have been first protected
> by a #ifndef guard to eliminate this transient warning, and there
> would be nothing to "fix" in this consolidation series.

That makes sense.  I can remove the fixes tags.  809216233555 will
likely be reverted first anyway, and you're right that the focus of
this patch series is on consolidating _GNU_SOURCE.


>
> Thoughts ?
>
> Thanks,
>
> Mathieu
>
> > Reviewed-by: John Hubbard 
> > Reviewed-by: Muhammad Usama Anjum 
> > Signed-off-by: Edward Liaw 
> > ---
> >   tools/testing/selftests/rseq/basic_percpu_ops_test.c | 1 -
> >   tools/testing/selftests/rseq/basic_test.c| 2 --
> >   tools/testing/selftests/rseq/param_test.c| 1 -
> >   tools/testing/selftests/rseq/rseq.c  | 2 --
> >   4 files changed, 6 deletions(-)
> >
> > diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c 
> > b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
> > index 2348d2c20d0a..5961c24ee1ae 100644
> > --- a/tools/testing/selftests/rseq/basic_percpu_ops_test.c
> > +++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
> > @@ -1,5 +1,4 @@
> >   // SPDX-License-Identifier: LGPL-2.1
> > -#define _GNU_SOURCE
> >   #include 
> >   #include 
> >   #include 
> > diff --git a/tools/testing/selftests/rseq/basic_test.c 
> > b/tools/testing/selftests/rseq/basic_test.c
> > index 295eea16466f..1fed749b4bd7 100644
> > --- a/tools/testing/selftests/rseq/basic_test.c
> > +++ b/tools/testing/selftests/rseq/basic_test.c
> > @@ -2,8 +2,6 @@
> >   /*
> >* Basic test coverage for critical regions and rseq_current_cpu().
> >*/
> > -
> > -#define _GNU_SOURCE
> >   #include 
> >   #include 
> >   #include 
> > diff --git a/tools/testing/selftests/rseq/param_test.c 
> > b/tools/testing/selftests/rseq/param_test.c
> > index 2f37961240ca..48a55d94eb72 100644
> > --- a/tools/testing/selftests/rseq/param_test.c
> > +++ b/tools/testing/selftests/rseq/param_test.c
> > @@ -1,5 +1,4 @@
> >   // SPDX-License-Identifier: LGPL-2.1
> > -#define _GNU_SOURCE
> >   #include 
> >   #include 
> >   #include 
> > diff --git a/tools/testing/selftests/rseq/rseq.c 
> > b/tools/testing/selftests/rseq/rseq.c
> > index 96e812bdf8a4..88602889414c 100644
> > --- a/tools/testing/selftests/rseq/rseq.c
> > +++ b/tools/testing/selftests/rseq/rseq.c
> > @@ -14,8 +14,6 @@
> >* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> >* Lesser General Public License for more details.
> >*/
> > -
> > -#define _GNU_SOURCE
> >   #include 
> >   #include 
> >   #include 
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> https://www.efficios.com
>



Re: [PATCH v2 4/4] selftests/resctrl: Enable MBA/MBA tests on AMD

2024-05-09 Thread Reinette Chatre



On 4/26/2024 12:06 AM, Ilpo Järvinen wrote:
> On Thu, 25 Apr 2024, Babu Moger wrote:
> 
>> Enable MBA/MBM tests if UMC (Unified Memory Controller) support is
>> available on the system. Tests will be skipped otherwise.
>>
>> Update noncont_cat_run_test to check for vendor. AMD supports
>> non contiguous CBM masks but does not report it via CPUID.
>>
>> Signed-off-by: Babu Moger 
>> ---
>>  tools/testing/selftests/resctrl/cat_test.c | 2 +-
>>  tools/testing/selftests/resctrl/mba_test.c | 1 -
>>  tools/testing/selftests/resctrl/mbm_test.c | 1 -
>>  3 files changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/tools/testing/selftests/resctrl/cat_test.c 
>> b/tools/testing/selftests/resctrl/cat_test.c
>> index 4cb991be8e31..b682eaf65bfd 100644
>> --- a/tools/testing/selftests/resctrl/cat_test.c
>> +++ b/tools/testing/selftests/resctrl/cat_test.c
>> @@ -314,7 +314,7 @@ static int noncont_cat_run_test(const struct 
>> resctrl_test *test,
>>  else
>>  return -EINVAL;
>>  
>> -if (sparse_masks != ((ecx >> 3) & 1)) {
>> +if ((get_vendor() == ARCH_INTEL) && sparse_masks != ((ecx >> 3) & 1)) {
> 
> This looks independent change to me which should be put into own patch.
> 

Own patch that is separate from this series. This should go in
as a fix with
Fixes: ae638551ab64 ("selftests/resctrl: Add non-contiguous CBMs CAT test")

Reinette



Re: [PATCH v2 3/4] selftests/resctrl: Add support for MBM and MBA tests on AMD

2024-05-09 Thread Reinette Chatre
Hi Babu,

On 4/25/2024 1:17 PM, Babu Moger wrote:
> Add support to read UMC (Unified Memory Controller) perf events to compare
> the numbers with QoS monitor for AMD.
> 
> Signed-off-by: Babu Moger 
> ---
>  tools/testing/selftests/resctrl/resctrl_val.c | 67 ---
>  1 file changed, 59 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c 
> b/tools/testing/selftests/resctrl/resctrl_val.c
> index e3b09128ec3d..d90d3196d7b5 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -11,6 +11,7 @@
>  #include "resctrl.h"
>  
>  #define UNCORE_IMC   "uncore_imc"
> +#define AMD_UMC  "amd_umc"
>  #define READ_FILE_NAME   "events/cas_count_read"
>  #define WRITE_FILE_NAME  "events/cas_count_write"
>  #define DYN_PMU_PATH "/sys/bus/event_source/devices"
> @@ -146,6 +147,47 @@ static int open_perf_event(int i, int cpu_no, int j)
>   return 0;
>  }
>  
> +/* Get type and config (read and write) of an UMC counter */
> +static int read_from_umc_dir(char *umc_dir, int count)
> +{
> + char umc_counter_type[PATH_MAX];
> + FILE *fp;
> +
> + /* Get type of iMC counter */

iMC counter?

> + sprintf(umc_counter_type, "%s%s", umc_dir, "type");
> + fp = fopen(umc_counter_type, "r");
> + if (!fp) {
> + ksft_perror("Failed to open imc counter type file");

Why go through effort of changing to generic names and then follow
by using Intel naming in AMD specific code?

> + return -1;
> + }
> +
> + if (fscanf(fp, "%u", _counters_config[count][READ].type) <= 0) {
> + ksft_perror("Could not get imc type");

Same here.

> + fclose(fp);
> + return -1;
> + }
> +
> + fclose(fp);
> +
> + imc_counters_config[count][WRITE].type =
> + imc_counters_config[count][READ].type;
> +

Up to here seems to be a copy of read_from_imc_dir(). Could you
instead split read_from_imc_dir() so that AMD and Intel can share the
code to determine type?

Reinette



Re: [PATCH v2 2/4] selftests/resctrl: Pass sysfs controller name of the vendor

2024-05-09 Thread Reinette Chatre
Hi Babu,

On 4/25/2024 1:17 PM, Babu Moger wrote:
> Detect the vendor and pass the sysfs name for the vendor for searching
> the controller information.

Could you please write a proper changelog?

> 
> Signed-off-by: Babu Moger 
> ---
>  tools/testing/selftests/resctrl/resctrl_val.c | 16 +---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c 
> b/tools/testing/selftests/resctrl/resctrl_val.c
> index a30cfcff605f..e3b09128ec3d 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -224,14 +224,24 @@ static int num_of_mem_controllers(void)
>  {
>   char imc_dir[512], *temp;
>   unsigned int count = 0;
> + int ret, vendor, size;
>   struct dirent *ep;
> - int ret;
> + char *sysfs_name;
>   DIR *dp;
>  
> + vendor = get_vendor();
> + if (vendor == ARCH_INTEL) {
> + sysfs_name = UNCORE_IMC;
> + size = sizeof(UNCORE_IMC);

Why is separate size needed? Can strlen() just be used when needed?

> + } else {
> + perror("Unsupported Vendor!\n");

ksft_perror()?

In the message, "Vendor" need not start with capital. It may also
help to print the vendor value in this unlikely case.

> + return -1;
> + }
> +
>   dp = opendir(DYN_PMU_PATH);
>   if (dp) {
>   while ((ep = readdir(dp))) {
> - temp = strstr(ep->d_name, UNCORE_IMC);
> + temp = strstr(ep->d_name, sysfs_name);
>   if (!temp)
>   continue;
>  
> @@ -242,7 +252,7 @@ static int num_of_mem_controllers(void)
>* well and hence the last underscore character in
>* uncore_imc'_' need not be counted.
>*/
> - temp = temp + sizeof(UNCORE_IMC);
> + temp = temp + size;

strlen()? (Keeping in mind the adjustment for the "_" character).

>  
>   /*
>* Some directories under "DYN_PMU_PATH" could have

Reinette



Re: [PATCH v2 1/4] selftests/resctrl: Rename variable imcs and num_of_imcs() to generic names

2024-05-09 Thread Reinette Chatre
Hi Babu,

On 4/25/2024 1:16 PM, Babu Moger wrote:
> In an effort to support MBM and MBA tests for AMD, renaming for variable
> and functions to generic names. For Intel, the memory controller is called
> Integrated Memory Controllers (IMC). For AMD, it is called Unified
> Memory Controller (UMC). No functional change.

This is a resonable change yet the actual changes seem inconsistent to me.
Per the changelog the goal is to switch from "IMC" specific naming to generic
"MC" naming in all the code that will be shared between AMD and Intel.
>From what I can tell this patch only changes *some* of the shared variables,
functions, and data structures and it is not obvious to me why some are
changed and some are not. This makes the code inconsistent.

There are many examples of the inconsistencies in this patch alone that
I will try to highlight what I mean without considering areas untouched by
this patch.
 
> Signed-off-by: Babu Moger 
> ---
>  tools/testing/selftests/resctrl/resctrl_val.c | 59 ++-
>  1 file changed, 30 insertions(+), 29 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c 
> b/tools/testing/selftests/resctrl/resctrl_val.c
> index 5a49f07a6c85..a30cfcff605f 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -60,7 +60,7 @@ struct imc_counter_config {
>  };
>  
>  static char mbm_total_path[1024];
> -static int imcs;
> +static int mcs;
>  static struct imc_counter_config imc_counters_config[MAX_IMCS][2];

Global "imcs" is changed to "mcs" ... but why are
global imc_counters_config[][] and its struct imc_counter_config
not changed?

>  
>  void membw_initialize_perf_event_attr(int i, int j)
> @@ -211,15 +211,16 @@ static int read_from_imc_dir(char *imc_dir, int count)
>  }
>  
>  /*
> - * A system can have 'n' number of iMC (Integrated Memory Controller)
> - * counters, get that 'n'. For each iMC counter get it's type and config.
> + * A system can have 'n' number of iMC (Integrated Memory Controller for
> + * Intel) counters, get that 'n'. In case of AMD it is called UMC (Unified
> + * Memory Controller). For each iMC/UMC counter get it's type and config.
>   * Also, each counter has two configs, one for read and the other for write.
>   * A config again has two parts, event and umask.
>   * Enumerate all these details into an array of structures.
>   *
>   * Return: >= 0 on success. < 0 on failure.
>   */
> -static int num_of_imcs(void)
> +static int num_of_mem_controllers(void)
>  {
>   char imc_dir[512], *temp;

Similarly, what about imc_dir[]?

>   unsigned int count = 0;
> @@ -275,25 +276,25 @@ static int num_of_imcs(void)
>   return count;
>  }
>  
> -static int initialize_mem_bw_imc(void)
> +static int initialize_mem_bw_mc(void)
>  {
> - int imc, j;
> + int mc, j;
>  
> - imcs = num_of_imcs();
> - if (imcs <= 0)
> - return imcs;
> + mcs = num_of_mem_controllers();
> + if (mcs <= 0)
> + return mcs;
>  
>   /* Initialize perf_event_attr structures for all iMC's */

Note comment still refers to iMC

> - for (imc = 0; imc < imcs; imc++) {
> + for (mc = 0; mc < mcs; mc++) {
>   for (j = 0; j < 2; j++)
> - membw_initialize_perf_event_attr(imc, j);
> + membw_initialize_perf_event_attr(mc, j);
>   }
>  
>   return 0;
>  }
>  
>  /*
> - * get_mem_bw_imc:   Memory band width as reported by iMC counters
> + * get_mem_bw_mc:Memory band width as reported by iMC counters

Comment still refers to iMC

>   * @cpu_no:  CPU number that the benchmark PID is binded to
>   * @bw_report:   Bandwidth report type (reads, writes)
>   *
> @@ -302,40 +303,40 @@ static int initialize_mem_bw_imc(void)
>   *
>   * Return: = 0 on success. < 0 on failure.
>   */
> -static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)
> +static int get_mem_bw_mc(int cpu_no, char *bw_report, float *bw_imc)

The intent of the function is to "get" bw_mc ... so not renaming "bw_imc"
seems like a miss. Especially when considering that its caller does just this.

>  {
>   float reads, writes, of_mul_read, of_mul_write;
> - int imc, j, ret;
> + int mc, j, ret;
>  
>   /* Start all iMC counters to log values (both read and write) */

iMC?

>   reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1;
> - for (imc = 0; imc < imcs; imc++) {
> + for (mc = 0; mc < mcs; mc++) {
>   for (j = 0; j < 2; j++) {
> - ret = open_perf_event(imc, cpu_no, j);
> + ret = open_perf_event(mc, cpu_no, j);
>   if (ret)
>   return -1;
>   }
>   for (j = 0; j < 2; j++)
> - membw_ioctl_perf_event_ioc_reset_enable(imc, j);
> + membw_ioctl_perf_event_ioc_reset_enable(mc, j);
>   }
>  
>   

Re: [PATCH v2 0/4] selftests/resctrl: Enable MBM and MBA tests on AMD

2024-05-09 Thread Reinette Chatre
Hi Babu,

On 4/25/2024 1:16 PM, Babu Moger wrote:
> 
> The MBM (Memory Bandwidth Monitoring) and MBA (Memory Bandwidth Allocation)
> features are not enabled for AMD systems. The reason was lack of perf
> counters to compare the resctrl test results.
> 
> Starting with the commit
> 25e56847821f ("perf/x86/amd/uncore: Add memory controller support"), AMD
> now supports the UMC (Unified Memory Controller) perf events. These events
> can be used to compare the test results.
> 
> This series adds the support to detect the UMC events and enable MBM/MBA
> tests for AMD systems.
> 
> v2: Changes.
> a. Rebased on top of tip/master (Apr 25, 2024)

Please note that resctrl selftest changes flow upstream via the kselftest
repo. The latest resctrl selftest changes can be found on the "next" branch
there.

Reinette



Re: [PATCH bpf-next 2/6] selftests/bpf: Use start_server_addr in sockopt_inherit

2024-05-09 Thread Martin KaFai Lau

On 5/5/24 4:35 AM, Geliang Tang wrote:

From: Geliang Tang 

Include network_helpers.h in prog_tests/sockopt_inherit.c, use public
helper start_server_addr() instead of the local defined function
start_server(). This can avoid duplicate code.

Add a helper custom_cb() to set SOL_CUSTOM sockopt looply, set it to
post_socket_cb pointer of struct network_helper_opts, and pass it to
start_server_addr().

Signed-off-by: Geliang Tang 
---
  .../bpf/prog_tests/sockopt_inherit.c  | 32 +++
  1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c 
b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c
index 917f486db826..ff0694ef5286 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c
@@ -1,6 +1,7 @@
  // SPDX-License-Identifier: GPL-2.0
  #include 
  #include "cgroup_helpers.h"
+#include "network_helpers.h"
  
  #include "sockopt_inherit.skel.h"
  
@@ -98,23 +99,12 @@ static void *server_thread(void *arg)

return (void *)(long)err;
  }
  
-static int start_server(void)

+static int custom_cb(int fd, const struct post_socket_opts *opts)
  {
-   struct sockaddr_in addr = {
-   .sin_family = AF_INET,
-   .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
-   };
char buf;
int err;
-   int fd;
int i;
  
-	fd = socket(AF_INET, SOCK_STREAM, 0);

-   if (fd < 0) {
-   log_err("Failed to create server socket");
-   return -1;
-   }
-
for (i = CUSTOM_INHERIT1; i <= CUSTOM_LISTENER; i++) {
buf = 0x01;
err = setsockopt(fd, SOL_CUSTOM, i, , 1);


There is a close(fd) on the error case a few lines below (not in this diff 
context). The caller (network_helpers.c) will also close it. I removed the 
close(fd) from the custom_cb() here.


Thanks for the patches. Applied.


@@ -125,20 +115,21 @@ static int start_server(void)
}
}
  
-	if (bind(fd, (const struct sockaddr *), sizeof(addr)) < 0) {

-   log_err("Failed to bind socket");
-   close(fd);
-   return -1;
-   }
-
-   return fd;
+   return 0;
  }
  





Re: [PATCH bpf-next 0/6] use network helpers, part 4

2024-05-09 Thread patchwork-bot+netdevbpf
Hello:

This series was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau :

On Sun,  5 May 2024 19:35:07 +0800 you wrote:
> From: Geliang Tang 
> 
> This patchset adds post_socket_cb pointer together with 'struct
> post_socket_opts cb_opts' into struct network_helper_opts to make
> start_server_addr() helper more flexible. With these modifications,
> many duplicate codes can be dropped.
> 
> [...]

Here is the summary with links:
  - [bpf-next,1/6] selftests/bpf: Add post_socket_cb for network_helper_opts
https://git.kernel.org/bpf/bpf-next/c/20434d2d896f
  - [bpf-next,2/6] selftests/bpf: Use start_server_addr in sockopt_inherit
https://git.kernel.org/bpf/bpf-next/c/5166b3e3e30a
  - [bpf-next,3/6] selftests/bpf: Use start_server_addr in 
test_tcp_check_syncookie
https://git.kernel.org/bpf/bpf-next/c/49e1fa8dbd81
  - [bpf-next,4/6] selftests/bpf: Use connect_to_fd in sockopt_inherit
https://git.kernel.org/bpf/bpf-next/c/5059c73eca67
  - [bpf-next,5/6] selftests/bpf: Use connect_to_fd in test_tcp_check_syncookie
https://git.kernel.org/bpf/bpf-next/c/65a3f0df44dd
  - [bpf-next,6/6] selftests/bpf: Drop get_port in test_tcp_check_syncookie
https://git.kernel.org/bpf/bpf-next/c/7abbf38cd8ed

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html





Re: [PATCH v3 04/29] riscv: zicfilp / zicfiss in dt-bindings (extensions.yaml)

2024-05-09 Thread Conor Dooley
On Thu, May 09, 2024 at 11:46:26AM -0700, Deepak Gupta wrote:
> On Thu, May 09, 2024 at 07:14:26PM +0100, Conor Dooley wrote:
> > On Tue, Apr 16, 2024 at 08:44:16AM -0700, Deepak Gupta wrote:
> > > On Mon, Apr 15, 2024 at 02:41:05PM -0500, Rob Herring wrote:
> > > > On Wed, Apr 10, 2024 at 02:37:21PM -0700, Deepak Gupta wrote:
> > > > > On Wed, Apr 10, 2024 at 4:58 AM Rob Herring  wrote:
> > > > > >
> > > > > > On Wed, Apr 03, 2024 at 04:34:52PM -0700, Deepak Gupta wrote:
> > > > > > > Make an entry for cfi extensions in extensions.yaml.
> > > > > > >
> > > > > > > Signed-off-by: Deepak Gupta 
> > > > > > > ---
> > > > > > >  .../devicetree/bindings/riscv/extensions.yaml  | 10 
> > > > > > > ++
> > > > > > >  1 file changed, 10 insertions(+)
> > > > > > >
> > > > > > > diff --git 
> > > > > > > a/Documentation/devicetree/bindings/riscv/extensions.yaml 
> > > > > > > b/Documentation/devicetree/bindings/riscv/extensions.yaml
> > > > > > > index 63d81dc895e5..45b87ad6cc1c 100644
> > > > > > > --- a/Documentation/devicetree/bindings/riscv/extensions.yaml
> > > > > > > +++ b/Documentation/devicetree/bindings/riscv/extensions.yaml
> > > > > > > @@ -317,6 +317,16 @@ properties:
> > > > > > >  The standard Zicboz extension for cache-block 
> > > > > > > zeroing as ratified
> > > > > > >  in commit 3dd606f ("Create cmobase-v1.0.pdf") of 
> > > > > > > riscv-CMOs.
> > > > > > >
> > > > > > > +- const: zicfilp
> > > > > > > +  description:
> > > > > > > +The standard Zicfilp extension for enforcing forward 
> > > > > > > edge control-flow
> > > > > > > +integrity in commit 3a20dc9 of riscv-cfi and is in 
> > > > > > > public review.
> > > > > >
> > > > > > Does in public review mean the commit sha is going to change?
> > > > > >
> > > > >
> > > > > Less likely. Next step after public review is to gather comments from
> > > > > public review.
> > > > > If something is really pressing and needs to be addressed, then yes
> > > > > this will change.
> > > > > Else this gets ratified as it is.
> > > >
> > > > If the commit sha can change, then it is useless. What's the guarantee
> > > > someone is going to remember to update it if it changes?
> > > 
> > > Sorry for late reply.
> > > 
> > > I was following existing wordings and patterns for messaging in this file.
> > > You would rather have me remove sha and only mention that spec is in 
> > > public
> > > review?
> > 
> > Nope, having a commit sha is desired. None of this is mergeable until at
> > least the spec becomes frozen, so the sha can be updated at that point
> > to the freeze state - or better yet to the ratified state. Being in
> > public review is not sufficient.
> 
> Spec is frozen.
> As per RVI spec lifecycle, spec freeze is a prior step to public review.
> Public review concluded on 25th April
> https://lists.riscv.org/g/tech-ss-lp-cfi/message/91
> 
> Next step is ratification whenever board meets.

Ah, I did the "silly" thing of looking on the RVI website at extension
status (because I never know the order of things) and these two
extensions were marked on there as being in the inception phase, so I
incorrectly assumed that "public review" came before freeze.
Freeze is the standard that we have been applying so far, but if
ratification is imminent, and nothing has changed in the review period,
then it seems sane to just pick the freeze point for the definition.

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH v3 13/68] selftests/damon: Drop define _GNU_SOURCE

2024-05-09 Thread SeongJae Park
Hi Edward,

On Thu,  9 May 2024 19:58:05 + Edward Liaw  wrote:

> _GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
> redefinition warnings.
> 
> Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")

I show Mathieu's comment on this[1].  I have no strong opinion on this, but if
you conclude to remove or change this line, please apply same change to this
patch.

[1] https://lore.kernel.org/638a7831-493c-4917-9b22-5aa663e9e...@efficios.com

> Signed-off-by: Edward Liaw 

I also added trivial comments that coming from my personal and humble
preferrence below.  Other than the above and the below comments,

Reviewed-by: SeongJae Park 

> ---
>  tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c| 3 ---
>  .../damon/debugfs_target_ids_read_before_terminate_race.c  | 2 --
>  2 files changed, 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c 
> b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
> index 0cc2eef7d142..7a17a03d555c 100644
> --- a/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
> +++ b/tools/testing/selftests/damon/debugfs_target_ids_pid_leak.c
> @@ -2,9 +2,6 @@
>  /*
>   * Author: SeongJae Park 
>   */
> -
> -#define _GNU_SOURCE
> -
>  #include 

I'd prefer having one empty line between the comment and includes.

>  #include 
>  #include 
> diff --git 
> a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
>  
> b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
> index b06f52a8ce2d..4aeac55ac93e 100644
> --- 
> a/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
> +++ 
> b/tools/testing/selftests/damon/debugfs_target_ids_read_before_terminate_race.c
> @@ -2,8 +2,6 @@
>  /*
>   * Author: SeongJae Park 
>   */
> -#define _GNU_SOURCE
> -
>  #include 

Ditto.

And I realize I also forgot adding one empty line before the above #define
line.  That's why I'm saying this is just a trivial comment :)

>  #include 
>  #include 
> -- 
> 2.45.0.118.g7fe29c98d7-goog


Thanks,
SJ



Re: [PATCH bpf-next 1/6] selftests/bpf: Add post_socket_cb for network_helper_opts

2024-05-09 Thread Martin KaFai Lau

On 5/5/24 4:35 AM, Geliang Tang wrote:

From: Geliang Tang 

__start_server() sets SO_REUSPORT through setsockopt() when the parameter
'reuseport' is set. This patch makes it more flexible by adding a function
pointer post_socket_cb, together with 'struct post_socket_opts cb_opts'
for future extension into struct network_helper_opts. Then 'reuseport'
parameter can be dropped.

Now the original start_reuseport_server() can be implemented by setting a
newly defined reuseport_cb() function pointer to post_socket_cb filed of
struct network_helper_opts.

Signed-off-by: Geliang Tang 
---
  tools/testing/selftests/bpf/network_helpers.c | 25 ---
  tools/testing/selftests/bpf/network_helpers.h |  4 +++
  2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/bpf/network_helpers.c 
b/tools/testing/selftests/bpf/network_helpers.c
index 054d26e383e0..a7ab05baedb6 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -81,9 +81,8 @@ int settimeo(int fd, int timeout_ms)
  #define save_errno_close(fd) ({ int __save = errno; close(fd); errno = 
__save; })
  
  static int __start_server(int type, const struct sockaddr *addr, socklen_t addrlen,

- bool reuseport, const struct network_helper_opts 
*opts)
+ const struct network_helper_opts *opts)
  {
-   int on = 1;
int fd;
  
  	fd = socket(addr->sa_family, type, opts->proto);

@@ -95,9 +94,9 @@ static int __start_server(int type, const struct sockaddr 
*addr, socklen_t addrl
if (settimeo(fd, opts->timeout_ms))
goto error_close;
  
-	if (reuseport &&

-   setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, , sizeof(on))) {
-   log_err("Failed to set SO_REUSEPORT");
+   if (opts->post_socket_cb &&
+   opts->post_socket_cb(fd, >cb_opts)) {
+   log_err("Failed to call post_socket_cb");
goto error_close;
}
  
@@ -132,7 +131,14 @@ int start_server(int family, int type, const char *addr_str, __u16 port,

if (make_sockaddr(family, addr_str, port, , ))
return -1;
  
-	return __start_server(type, (struct sockaddr *), addrlen, false, );

+   return __start_server(type, (struct sockaddr *), addrlen, );
+}
+
+static int reuseport_cb(int fd, const struct post_socket_opts *opts)
+{
+   int on = 1;
+
+   return setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, , sizeof(on));
  }
  
  int *start_reuseport_server(int family, int type, const char *addr_str,

@@ -140,6 +146,7 @@ int *start_reuseport_server(int family, int type, const 
char *addr_str,
  {
struct network_helper_opts opts = {
.timeout_ms = timeout_ms,
+   .post_socket_cb = reuseport_cb,
};
struct sockaddr_storage addr;
unsigned int nr_fds = 0;
@@ -156,7 +163,7 @@ int *start_reuseport_server(int family, int type, const 
char *addr_str,
if (!fds)
return NULL;
  
-	fds[0] = __start_server(type, (struct sockaddr *), addrlen, true, );

+   fds[0] = __start_server(type, (struct sockaddr *), addrlen, );
if (fds[0] == -1)
goto close_fds;
nr_fds = 1;
@@ -165,7 +172,7 @@ int *start_reuseport_server(int family, int type, const 
char *addr_str,
goto close_fds;
  
  	for (; nr_fds < nr_listens; nr_fds++) {

-   fds[nr_fds] = __start_server(type, (struct sockaddr *), 
addrlen, true, );
+   fds[nr_fds] = __start_server(type, (struct sockaddr *), 
addrlen, );
if (fds[nr_fds] == -1)
goto close_fds;
}
@@ -183,7 +190,7 @@ int start_server_addr(int type, const struct 
sockaddr_storage *addr, socklen_t l
if (!opts)
opts = _opts;
  
-	return __start_server(type, (struct sockaddr *)addr, len, 0, opts);

+   return __start_server(type, (struct sockaddr *)addr, len, opts);
  }
  
  void free_fds(int *fds, unsigned int nr_close_fds)

diff --git a/tools/testing/selftests/bpf/network_helpers.h 
b/tools/testing/selftests/bpf/network_helpers.h
index c62b54daa914..887075fbf6ec 100644
--- a/tools/testing/selftests/bpf/network_helpers.h
+++ b/tools/testing/selftests/bpf/network_helpers.h
@@ -21,6 +21,8 @@ typedef __u16 __sum16;
  #define VIP_NUM 5
  #define MAGIC_BYTES 123
  
+struct post_socket_opts {};

+
  struct network_helper_opts {
const char *cc;
int timeout_ms;
@@ -28,6 +30,8 @@ struct network_helper_opts {
bool noconnect;
int type;
int proto;
+   int (*post_socket_cb)(int fd, const struct post_socket_opts *opts);
+   struct post_socket_opts cb_opts;


I am going to remove cb_opts from network_helper_opts for now. Lets wait for the 
first use case of post_socket_opts comes up. NULL is always passed to 
post_socket_cb for now.



  };
  
  /* ipv4 test vector */





Re: [PATCH v3 54/68] selftests/rseq: Drop define _GNU_SOURCE

2024-05-09 Thread Mathieu Desnoyers

On 2024-05-09 15:58, Edward Liaw wrote:

_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")


The patch per se looks fine, except for the "Fixes" tag.

Commit 809216233555 introduces use of asprintf in kselftest_harness.h
which is used by (all ?) selftests, including the rseq ones. However,
the rseq selftests each have the #define _GNU_SOURCE, which would have
been OK without those further changes.

So this patch is more about consolidating where the _GNU_SOURCE is
defined, which is OK with me, but not so much about "fixing" an
issue with commit 809216233555.

A "Fix" is something to be backported to stable kernels, and I
don't think this patch reaches that threshold.

If anything, this patch removes a warning that gets added by
https://lore.kernel.org/lkml/20240509200022.253089-1-edl...@google.com/T/#mf8438d03de6e2b613da4f86d4f60c5fe1c5f8483
within the same series.

Arguably, each #define _GNU_SOURCE could have been first protected
by a #ifndef guard to eliminate this transient warning, and there
would be nothing to "fix" in this consolidation series.

Thoughts ?

Thanks,

Mathieu


Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
  tools/testing/selftests/rseq/basic_percpu_ops_test.c | 1 -
  tools/testing/selftests/rseq/basic_test.c| 2 --
  tools/testing/selftests/rseq/param_test.c| 1 -
  tools/testing/selftests/rseq/rseq.c  | 2 --
  4 files changed, 6 deletions(-)

diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c 
b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
index 2348d2c20d0a..5961c24ee1ae 100644
--- a/tools/testing/selftests/rseq/basic_percpu_ops_test.c
+++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
@@ -1,5 +1,4 @@
  // SPDX-License-Identifier: LGPL-2.1
-#define _GNU_SOURCE
  #include 
  #include 
  #include 
diff --git a/tools/testing/selftests/rseq/basic_test.c 
b/tools/testing/selftests/rseq/basic_test.c
index 295eea16466f..1fed749b4bd7 100644
--- a/tools/testing/selftests/rseq/basic_test.c
+++ b/tools/testing/selftests/rseq/basic_test.c
@@ -2,8 +2,6 @@
  /*
   * Basic test coverage for critical regions and rseq_current_cpu().
   */
-
-#define _GNU_SOURCE
  #include 
  #include 
  #include 
diff --git a/tools/testing/selftests/rseq/param_test.c 
b/tools/testing/selftests/rseq/param_test.c
index 2f37961240ca..48a55d94eb72 100644
--- a/tools/testing/selftests/rseq/param_test.c
+++ b/tools/testing/selftests/rseq/param_test.c
@@ -1,5 +1,4 @@
  // SPDX-License-Identifier: LGPL-2.1
-#define _GNU_SOURCE
  #include 
  #include 
  #include 
diff --git a/tools/testing/selftests/rseq/rseq.c 
b/tools/testing/selftests/rseq/rseq.c
index 96e812bdf8a4..88602889414c 100644
--- a/tools/testing/selftests/rseq/rseq.c
+++ b/tools/testing/selftests/rseq/rseq.c
@@ -14,8 +14,6 @@
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   */
-
-#define _GNU_SOURCE
  #include 
  #include 
  #include 


--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com




[PATCH v3 68/68] selftests/x86: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Drop #define __USE_GNU too, as it is bad practice and the GNU extensions
aren't actually being used in test_FCMOV, etc. where it is being defined.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/x86/amx.c | 2 --
 tools/testing/selftests/x86/check_initial_reg_state.c | 3 ---
 tools/testing/selftests/x86/corrupt_xstate_header.c   | 3 ---
 tools/testing/selftests/x86/entry_from_vm86.c | 3 ---
 tools/testing/selftests/x86/fsgsbase.c| 2 --
 tools/testing/selftests/x86/fsgsbase_restore.c| 2 --
 tools/testing/selftests/x86/ioperm.c  | 2 --
 tools/testing/selftests/x86/iopl.c| 2 --
 tools/testing/selftests/x86/lam.c | 1 -
 tools/testing/selftests/x86/ldt_gdt.c | 2 --
 tools/testing/selftests/x86/mov_ss_trap.c | 2 --
 tools/testing/selftests/x86/nx_stack.c| 2 --
 tools/testing/selftests/x86/ptrace_syscall.c  | 2 --
 tools/testing/selftests/x86/sigaltstack.c | 2 --
 tools/testing/selftests/x86/sigreturn.c   | 3 ---
 tools/testing/selftests/x86/single_step_syscall.c | 3 ---
 tools/testing/selftests/x86/syscall_arg_fault.c   | 3 ---
 tools/testing/selftests/x86/syscall_numbering.c   | 3 ---
 tools/testing/selftests/x86/sysret_rip.c  | 3 ---
 tools/testing/selftests/x86/sysret_ss_attrs.c | 3 ---
 tools/testing/selftests/x86/test_FCMOV.c  | 4 
 tools/testing/selftests/x86/test_FCOMI.c  | 4 
 tools/testing/selftests/x86/test_FISTTP.c | 4 
 tools/testing/selftests/x86/test_mremap_vdso.c| 1 -
 tools/testing/selftests/x86/test_shadow_stack.c   | 3 ---
 tools/testing/selftests/x86/test_syscall_vdso.c   | 4 
 tools/testing/selftests/x86/test_vsyscall.c   | 3 ---
 tools/testing/selftests/x86/unwind_vdso.c | 3 ---
 tools/testing/selftests/x86/vdso_restorer.c   | 3 ---
 29 files changed, 77 deletions(-)

diff --git a/tools/testing/selftests/x86/amx.c 
b/tools/testing/selftests/x86/amx.c
index 95aad6d8849b..3259362a7117 100644
--- a/tools/testing/selftests/x86/amx.c
+++ b/tools/testing/selftests/x86/amx.c
@@ -1,6 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/check_initial_reg_state.c 
b/tools/testing/selftests/x86/check_initial_reg_state.c
index 3bc95f3ed585..0129cdae8abe 100644
--- a/tools/testing/selftests/x86/check_initial_reg_state.c
+++ b/tools/testing/selftests/x86/check_initial_reg_state.c
@@ -3,9 +3,6 @@
  * check_initial_reg_state.c - check that execve sets the correct state
  * Copyright (c) 2014-2016 Andrew Lutomirski
  */
-
-#define _GNU_SOURCE
-
 #include 
 
 unsigned long ax, bx, cx, dx, si, di, bp, sp, flags;
diff --git a/tools/testing/selftests/x86/corrupt_xstate_header.c 
b/tools/testing/selftests/x86/corrupt_xstate_header.c
index cf9ce8fbb656..d2c746149678 100644
--- a/tools/testing/selftests/x86/corrupt_xstate_header.c
+++ b/tools/testing/selftests/x86/corrupt_xstate_header.c
@@ -4,9 +4,6 @@
  *
  * Based on analysis and a test case from Thomas Gleixner.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/entry_from_vm86.c 
b/tools/testing/selftests/x86/entry_from_vm86.c
index d1e919b0c1dc..9fa9d4a847ac 100644
--- a/tools/testing/selftests/x86/entry_from_vm86.c
+++ b/tools/testing/selftests/x86/entry_from_vm86.c
@@ -5,9 +5,6 @@
  *
  * This exercises a few paths that need to special-case vm86 mode.
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/fsgsbase.c 
b/tools/testing/selftests/x86/fsgsbase.c
index 8c780cce941d..348134d2cefc 100644
--- a/tools/testing/selftests/x86/fsgsbase.c
+++ b/tools/testing/selftests/x86/fsgsbase.c
@@ -3,8 +3,6 @@
  * fsgsbase.c, an fsgsbase test
  * Copyright (c) 2014-2016 Andy Lutomirski
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/fsgsbase_restore.c 
b/tools/testing/selftests/x86/fsgsbase_restore.c
index 6fffadc51579..88dce47ab8e6 100644
--- a/tools/testing/selftests/x86/fsgsbase_restore.c
+++ b/tools/testing/selftests/x86/fsgsbase_restore.c
@@ -12,8 +12,6 @@
  *
  * This is not part of fsgsbase.c, because that test is 64-bit only.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/x86/ioperm.c 
b/tools/testing/selftests/x86/ioperm.c
index 57ec5e99edb9..07b7c10f8d39 100644
--- a/tools/testing/selftests/x86/ioperm.c
+++ b/tools/testing/selftests/x86/ioperm.c
@@ -3,8 +3,6 @@
  * ioperm.c - Test case for ioperm(2)
  * Copyright (c) 2015 Andrew 

[PATCH v3 67/68] selftests/wireguard: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/wireguard/qemu/init.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/wireguard/qemu/init.c 
b/tools/testing/selftests/wireguard/qemu/init.c
index 3e49924dd77e..08113f3c6189 100644
--- a/tools/testing/selftests/wireguard/qemu/init.c
+++ b/tools/testing/selftests/wireguard/qemu/init.c
@@ -2,8 +2,6 @@
 /*
  * Copyright (C) 2015-2019 Jason A. Donenfeld . All Rights 
Reserved.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v3 66/68] selftests/vDSO: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/vDSO/vdso_test_abi.c  | 1 -
 tools/testing/selftests/vDSO/vdso_test_clock_getres.c | 2 --
 tools/testing/selftests/vDSO/vdso_test_correctness.c  | 3 ---
 3 files changed, 6 deletions(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c 
b/tools/testing/selftests/vDSO/vdso_test_abi.c
index 96d32fd65b42..fb01e6ffb9a0 100644
--- a/tools/testing/selftests/vDSO/vdso_test_abi.c
+++ b/tools/testing/selftests/vDSO/vdso_test_abi.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#define _GNU_SOURCE
 #include 
 #include 
 
diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c 
b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
index 38d46a8bf7cb..f0adb906c8bd 100644
--- a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
+++ b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c
@@ -10,8 +10,6 @@
  * Power (32-bit and 64-bit), S390x (32-bit and 64-bit).
  * Might work on other architectures.
  */
-
-#define _GNU_SOURCE
 #include 
 #include 
 #include 
diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c 
b/tools/testing/selftests/vDSO/vdso_test_correctness.c
index e691a3cf1491..c435b7a5b38d 100644
--- a/tools/testing/selftests/vDSO/vdso_test_correctness.c
+++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c
@@ -3,9 +3,6 @@
  * ldt_gdt.c - Test cases for LDT and GDT access
  * Copyright (c) 2011-2015 Andrew Lutomirski
  */
-
-#define _GNU_SOURCE
-
 #include 
 #include 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




[PATCH v3 65/68] selftests/user_events: Drop define _GNU_SOURCE

2024-05-09 Thread Edward Liaw
_GNU_SOURCE is provided by lib.mk, so it should be dropped to prevent
redefinition warnings.

Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Reviewed-by: John Hubbard 
Reviewed-by: Muhammad Usama Anjum 
Signed-off-by: Edward Liaw 
---
 tools/testing/selftests/user_events/abi_test.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/testing/selftests/user_events/abi_test.c 
b/tools/testing/selftests/user_events/abi_test.c
index 7288a05136ba..a1f156dbbd56 100644
--- a/tools/testing/selftests/user_events/abi_test.c
+++ b/tools/testing/selftests/user_events/abi_test.c
@@ -4,8 +4,6 @@
  *
  * Copyright (c) 2022 Beau Belgrave 
  */
-
-#define _GNU_SOURCE
 #include 
 
 #include 
-- 
2.45.0.118.g7fe29c98d7-goog




  1   2   3   >