Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1933715ybm; Thu, 23 May 2019 08:50:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHibJyMTceTnjMFnj/EXQKlDYopsCjMOz9yEaBzxkVYrRkmG+lfUbP4cT5V0KcUdVSfJAi X-Received: by 2002:a17:90a:de08:: with SMTP id m8mr2144808pjv.18.1558626623515; Thu, 23 May 2019 08:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558626623; cv=none; d=google.com; s=arc-20160816; b=gPSrOexIUFCfvRQ8w7Cuhabn12mWpKfR6SkkDKDP7Yb7hbVpDiKnACfeXC6XbdaMhR FTNvVkGYCbWclalvFmhDbG5l5/wiQuS3PxaSLBKoHxpPeHCdyZVRYyl27SfnY6y37cKJ aK3aJC5t4BidG7xw2rp5I3Ijdj/QnilKvd2GM8BrwIRNRRUTp918blatDVPXbmTRzM6N 5ghNW+77tuWmkFuytMX9W7md3bN2sS6Vvlihzl4Kt6rTn6N4G2yng57FQOxdvEbY23gK sMjESNQAAhcl0YmwvXlAu/K1j6h+wnLIMWYrLTi8NoKFL2s96YRcrD5KLEslu+zKkORt 7XgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qdhvyBV5eCUYlrhtprSXvsuKWr+yBvkV1a8SbE6AS60=; b=m+3Dp0PddC0c1TciWJeEhHMTx868FGkhf4ro/KEyaHXyNJfCyCLMMwCa12B/fWcNp4 VuvHT01aXcQqkbpqwW0/RHgWifkXF41GmCWy1c87/Yk+9iVpLbu5s1cUh+yBIY/1LSCc RieYRzmjiRyJyp/pdZLTolHBiRzjewu6hY8SLslzmBV4g3KqzHoosIyKFdd54OjlJPo3 Kt5jirNVFsHvxN9bd6qofo2QCWjrFYnRSGZQ9+Fdt2eXC25Kk8TWji3KOv8SpRO1u0IU 8upeYLk7wQMluqDfYXlIl8Jq5NJCZ3COCrXwSoNfDQhLWlCbz8agLTh2D3ipdEYZfX1+ M/4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=PHFjvm23; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si30856857pgl.77.2019.05.23.08.50.07; Thu, 23 May 2019 08:50:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=PHFjvm23; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731073AbfEWPs7 (ORCPT + 99 others); Thu, 23 May 2019 11:48:59 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:54769 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731038AbfEWPs6 (ORCPT ); Thu, 23 May 2019 11:48:58 -0400 Received: by mail-it1-f193.google.com with SMTP id h20so10507448itk.4 for ; Thu, 23 May 2019 08:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qdhvyBV5eCUYlrhtprSXvsuKWr+yBvkV1a8SbE6AS60=; b=PHFjvm23caZGYr4uiNYmJAibVBzXG/G68GWrR3KEL+4ubMa1yG52PY5KbD5HgQ94DS UYyKxymb5fEjGeKdBKbPovN4lf1X37+9FR6/IKpeONALi6Pb6Ba6dCiyKGGLwyh/Thfo TBBGEFZCAqITH+9ysPxJvr8e5RDKlYMuQAQ4Vb/7fDfahu0Q9wvBEskpiiSkZAzXwDg0 HO3ghqNF44h7BZNoCoOH48Br+sXnnPudMYWxblMnUowckCT/7+BYIAVlMi8aQoMmK9+g efMaCVYPokznZ4LdQiFStyRq1hGeIabBZ6GksyGUTQGFowjocl7wKgtLYpmWvu2C2iki T5Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qdhvyBV5eCUYlrhtprSXvsuKWr+yBvkV1a8SbE6AS60=; b=s7Ir7JYYynKo7RKT8VbVYrkxka7WSwbltaqsPSjwSYeLKj7I5ajdEz7MkpGK+f7Wa+ cZWToDS7b1cc9bDBu78fNzx1kV/GraZTJU8TOxY8m2FGVJWzPPuR4sKWjTiAe2wS4SmH /Qg22lrD6yRgXXRL5QMPxePdSnOAibA61UcvzpdgCkilyaiWqVovk1JBlUuv4TV/VsRN Y6XCgJaFG88af/SEzWYfYgyKe0iWL+FvxFfAOWu8jvegMG7KcpJLGKuDUv+yqLjhgmFw IrGmvYmQTAVFy6atc7dtvQyRdMQqOUKesWYEWrJK13trbRZhxCpfVk5Cc3iUAmPd6xSG Guqw== X-Gm-Message-State: APjAAAVRhNthzBP8cgd8HU7Y4Rt0NI4/XYnOvzsYdrJzParqsXgPbcZs 7If2eE8A+KR57BkNNoeH7lWb/A== X-Received: by 2002:a24:6212:: with SMTP id d18mr13266189itc.2.1558626537435; Thu, 23 May 2019 08:48:57 -0700 (PDT) Received: from localhost.localdomain ([172.56.12.187]) by smtp.gmail.com with ESMTPSA id v1sm9124939iob.56.2019.05.23.08.48.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 May 2019 08:48:56 -0700 (PDT) From: Christian Brauner To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, torvalds@linux-foundation.org, fweimer@redhat.com Cc: jannh@google.com, oleg@redhat.com, tglx@linutronix.de, arnd@arndb.de, shuah@kernel.org, dhowells@redhat.com, tkjos@android.com, ldv@altlinux.org, miklos@szeredi.hu, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, x86@kernel.org, Christian Brauner Subject: [PATCH v2 0/2] close_range() Date: Thu, 23 May 2019 17:47:45 +0200 Message-Id: <20190523154747.15162-1-christian@brauner.io> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey, This is v2 of this patchset. In accordance with some comments There's a cond_resched() added to the close loop similar to what is done for close_files(). A common helper pick_file() for __close_fd() and __close_range() has been split out. This allows to only make a cond_resched() call when filp_close() has been called similar to what is done in close_files(). Maybe that's not worth it. Jann mentioned that cond_resched() looks rather cheap. So it maybe that we could simply do: while (fd <= max_fd) { __close(files, fd++); cond_resched(); } I also added a missing test for close_range(fd, fd, 0). Thanks! Christian Christian Brauner (2): open: add close_range() tests: add close_range() tests arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd32.h | 2 + arch/ia64/kernel/syscalls/syscall.tbl | 1 + arch/m68k/kernel/syscalls/syscall.tbl | 1 + arch/microblaze/kernel/syscalls/syscall.tbl | 1 + arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + arch/parisc/kernel/syscalls/syscall.tbl | 1 + arch/powerpc/kernel/syscalls/syscall.tbl | 1 + arch/s390/kernel/syscalls/syscall.tbl | 1 + arch/sh/kernel/syscalls/syscall.tbl | 1 + arch/sparc/kernel/syscalls/syscall.tbl | 1 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + fs/file.c | 62 +++++++- fs/open.c | 20 +++ include/linux/fdtable.h | 2 + include/linux/syscalls.h | 2 + include/uapi/asm-generic/unistd.h | 4 +- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/core/.gitignore | 1 + tools/testing/selftests/core/Makefile | 6 + .../testing/selftests/core/close_range_test.c | 142 ++++++++++++++++++ 26 files changed, 249 insertions(+), 9 deletions(-) create mode 100644 tools/testing/selftests/core/.gitignore create mode 100644 tools/testing/selftests/core/Makefile create mode 100644 tools/testing/selftests/core/close_range_test.c -- 2.21.0