public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] pipe/pipe15.c: Adjust fd check for pipe creation
@ 2024-03-01  2:12 xuwenjie04 via ltp
  2024-03-01 12:41 ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: xuwenjie04 via ltp @ 2024-03-01  2:12 UTC (permalink / raw)
  To: ltp@lists.linux.it

A pipe occupies 2 fds, and considering 3 standard fds,
we should compare rlim_max with such *2+3 calculated value
to verify whether the maximum file descriptor configuration
of the current machine is sufficient.

Signed-off-by: Wenjie Xu <xuwenjie04@baidu.com>
---
testcases/kernel/syscalls/pipe/pipe15.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/pipe/pipe15.c b/testcases/kernel/syscalls/pipe/pipe15.c
index c85ad1820..9e02fe2eb 100644
--- a/testcases/kernel/syscalls/pipe/pipe15.c
+++ b/testcases/kernel/syscalls/pipe/pipe15.c
@@ -59,7 +59,7 @@ static void setup(void)
      tst_res(TINFO, "Creating %i pipes", pipe_count);

      SAFE_GETRLIMIT(RLIMIT_NOFILE, &nfd);
-     if (nfd.rlim_max < (unsigned long)pipe_count)
+    if (nfd.rlim_max < (unsigned long)pipe_count * 2 + 3)
             tst_brk(TCONF, "NOFILE limit max too low: %lu < %i", nfd.rlim_max, pipe_count);
      if (nfd.rlim_cur < nfd.rlim_max) {
             nfd.rlim_cur = nfd.rlim_max;
--
2.41.0

--
Mailing list info: https://lists.linux.it/listinfo/ltp


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] pipe/pipe15.c: Adjust fd check for pipe creation
  2024-03-01  2:12 [LTP] [PATCH] pipe/pipe15.c: Adjust fd check for pipe creation xuwenjie04 via ltp
@ 2024-03-01 12:41 ` Petr Vorel
  2024-03-05  7:20   ` Wenjie Xu via ltp
  0 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2024-03-01 12:41 UTC (permalink / raw)
  To: xuwenjie04; +Cc: ltp@lists.linux.it

HI Wenjie, Marius,

> A pipe occupies 2 fds, and considering 3 standard fds,
> we should compare rlim_max with such *2+3 calculated value
> to verify whether the maximum file descriptor configuration
> of the current machine is sufficient.

Indeed, 1024*2+3 is the lowest number which passes with non-default ulimit:

ulimit -n $((1024*2+3)) && ./pipe15

Therefore I merged, thank you!

BTW I wonder how did you encounter this?

@Marius FYI I also fixed SIGSEGV when low ulimit, see
https://github.com/linux-test-project/ltp/commit/fc6adb8454df34fa87b462844b740cc3a0b84caa

> Signed-off-by: Wenjie Xu <xuwenjie04@baidu.com>
> ---
> testcases/kernel/syscalls/pipe/pipe15.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/testcases/kernel/syscalls/pipe/pipe15.c b/testcases/kernel/syscalls/pipe/pipe15.c
> index c85ad1820..9e02fe2eb 100644
> --- a/testcases/kernel/syscalls/pipe/pipe15.c
> +++ b/testcases/kernel/syscalls/pipe/pipe15.c
> @@ -59,7 +59,7 @@ static void setup(void)
>       tst_res(TINFO, "Creating %i pipes", pipe_count);

>       SAFE_GETRLIMIT(RLIMIT_NOFILE, &nfd);
> -     if (nfd.rlim_max < (unsigned long)pipe_count)
> +    if (nfd.rlim_max < (unsigned long)pipe_count * 2 + 3)
nit: you mixed tabs with spaces or broke indent. And patch was not applicable
(even before my changes), therefore I needed to do the changes myself and thus I
put my fix fc6adb845 ("pipe15: Avoid SIGSEGV in cleanup") before.

Kind regards,
Petr

>              tst_brk(TCONF, "NOFILE limit max too low: %lu < %i", nfd.rlim_max, pipe_count);
>       if (nfd.rlim_cur < nfd.rlim_max) {
>              nfd.rlim_cur = nfd.rlim_max;

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] pipe/pipe15.c: Adjust fd check for pipe creation
  2024-03-01 12:41 ` Petr Vorel
@ 2024-03-05  7:20   ` Wenjie Xu via ltp
  2024-03-06 12:46     ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Wenjie Xu via ltp @ 2024-03-05  7:20 UTC (permalink / raw)
  To: pvorel; +Cc: ltp

> HI Wenjie, Marius,
>
> > A pipe occupies 2 fds, and considering 3 standard fds,
> > we should compare rlim_max with such *2+3 calculated value
> > to verify whether the maximum file descriptor configuration
> > of the current machine is sufficient.
> 
> Indeed, 1024*2+3 is the lowest number which passes with non-default ulimit:
> 
> ulimit -n $((1024*2+3)) && ./pipe15
> 
> Therefore I merged, thank you!
> 
> BTW I wonder how did you encounter this?
 
In my test case, the system ulimit is set to 10240,
and the calculated pipe_count is also 10240, causing
the EMFILE failure when creating the pipe below.

> @Marius FYI I also fixed SIGSEGV when low ulimit, see
> https://github.com/linux-test-project/ltp/commit/fc6adb8454df34fa87b462844b740cc3a0b84caa
>
> > Signed-off-by: Wenjie Xu <xuwenjie04@baidu.com>
> > ---
> > testcases/kernel/syscalls/pipe/pipe15.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)

> > diff --git a/testcases/kernel/syscalls/pipe/pipe15.c b/testcases/kernel/syscalls/pipe/pipe15.c
> > index c85ad1820..9e02fe2eb 100644
> > --- a/testcases/kernel/syscalls/pipe/pipe15.c
> > +++ b/testcases/kernel/syscalls/pipe/pipe15.c
> > @@ -59,7 +59,7 @@ static void setup(void)
> >       tst_res(TINFO, "Creating %i pipes", pipe_count);
> 
> >       SAFE_GETRLIMIT(RLIMIT_NOFILE, &nfd);
> > -     if (nfd.rlim_max < (unsigned long)pipe_count)
> > +    if (nfd.rlim_max < (unsigned long)pipe_count * 2 + 3)
> nit: you mixed tabs with spaces or broke indent. And patch was not applicable
> (even before my changes), therefore I needed to do the changes myself and thus I
> put my fix fc6adb845 ("pipe15: Avoid SIGSEGV in cleanup") before.
> 
> Kind regards,
> Petr
>
> >              tst_brk(TCONF, "NOFILE limit max too low: %lu < %i", nfd.rlim_max, pipe_count);
> >       if (nfd.rlim_cur < nfd.rlim_max) {
> >              nfd.rlim_cur = nfd.rlim_max;

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] pipe/pipe15.c: Adjust fd check for pipe creation
  2024-03-05  7:20   ` Wenjie Xu via ltp
@ 2024-03-06 12:46     ` Petr Vorel
  2024-03-07  2:55       ` Wenjie Xu via ltp
  0 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2024-03-06 12:46 UTC (permalink / raw)
  To: Wenjie Xu; +Cc: ltp

> > HI Wenjie, Marius,

> > > A pipe occupies 2 fds, and considering 3 standard fds,
> > > we should compare rlim_max with such *2+3 calculated value
> > > to verify whether the maximum file descriptor configuration
> > > of the current machine is sufficient.

> > Indeed, 1024*2+3 is the lowest number which passes with non-default ulimit:

> > ulimit -n $((1024*2+3)) && ./pipe15

> > Therefore I merged, thank you!

> > BTW I wonder how did you encounter this?

> In my test case, the system ulimit is set to 10240,
> and the calculated pipe_count is also 10240, causing
> the EMFILE failure when creating the pipe below.

+1, thanks for info.
Is it some embedded distro or a regular widely used distro?
I'm just curious what kernels are tested by LTP and whether where the
non-default setup comes from.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH] pipe/pipe15.c: Adjust fd check for pipe creation
  2024-03-06 12:46     ` Petr Vorel
@ 2024-03-07  2:55       ` Wenjie Xu via ltp
  0 siblings, 0 replies; 5+ messages in thread
From: Wenjie Xu via ltp @ 2024-03-07  2:55 UTC (permalink / raw)
  To: pvorel; +Cc: ltp

> > > HI Wenjie, Marius,

> > > > A pipe occupies 2 fds, and considering 3 standard fds,
> > > > we should compare rlim_max with such *2+3 calculated value
> > > > to verify whether the maximum file descriptor configuration
> > > > of the current machine is sufficient.

> > > Indeed, 1024*2+3 is the lowest number which passes with non-default ulimit:

> > > ulimit -n $((1024*2+3)) && ./pipe15

> > > Therefore I merged, thank you!

> > > BTW I wonder how did you encounter this?

> > In my test case, the system ulimit is set to 10240,
> > and the calculated pipe_count is also 10240, causing
> > the EMFILE failure when creating the pipe below.

> +1, thanks for info.
> Is it some embedded distro or a regular widely used distro?
> I'm just curious what kernels are tested by LTP and whether where the
> non-default setup comes from.

> Kind regards,
> Petr

This may come from the modification of the kernel and image 
we maintain ourselves. The basic image is from CentOS 7.6.1810,
and the kernel based on version 5.10.

Regards,
Xu Wenjie

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-07  2:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01  2:12 [LTP] [PATCH] pipe/pipe15.c: Adjust fd check for pipe creation xuwenjie04 via ltp
2024-03-01 12:41 ` Petr Vorel
2024-03-05  7:20   ` Wenjie Xu via ltp
2024-03-06 12:46     ` Petr Vorel
2024-03-07  2:55       ` Wenjie Xu via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox