]> git.baikalelectronics.ru Git - kernel.git/commit
pipe: increase minimum default pipe size to 2 pages
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>
Thu, 5 Aug 2021 14:40:47 +0000 (10:40 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Aug 2021 11:21:02 +0000 (13:21 +0200)
commit51492e18f1bb8ee1b2f66d870f3d505d4d7bfcb6
treee07f39220a52cd5f29d74ea50dfaa27bacd9cc29
parentf97f4c3c849f9b8f37c2818c9539d6cad0e41d4f
pipe: increase minimum default pipe size to 2 pages

commit 46c4c9d1beb7f5b4cec4dd90e7728720583ee348 upstream.

This program always prints 4096 and hangs before the patch, and always
prints 8192 and exits successfully after:

  int main()
  {
      int pipefd[2];
      for (int i = 0; i < 1025; i++)
          if (pipe(pipefd) == -1)
              return 1;
      size_t bufsz = fcntl(pipefd[1], F_GETPIPE_SZ);
      printf("%zd\n", bufsz);
      char *buf = calloc(bufsz, 1);
      write(pipefd[1], buf, bufsz);
      read(pipefd[0], buf, bufsz-1);
      write(pipefd[1], buf, 1);
  }

Note that you may need to increase your RLIMIT_NOFILE before running the
program.

Fixes: aae470b538 ("pipe: limit the per-user amount of pages allocated in pipes")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/lkml/1628086770.5rn8p04n6j.none@localhost/
Link: https://lore.kernel.org/lkml/1628127094.lxxn016tj7.none@localhost/
Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/pipe.c