Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2119240imu; Sat, 5 Jan 2019 15:19:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/VKQeUC7wCm6u3dzHrFO1bwj488uPrQkLS109fR3aoCxNIX32jIfIfipOwo7P6ZzaNfklmJ X-Received: by 2002:a62:5c1:: with SMTP id 184mr57156380pff.165.1546730360590; Sat, 05 Jan 2019 15:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546730360; cv=none; d=google.com; s=arc-20160816; b=sZSIFDzbeftLdALjmCpp4Xas/cZQGfQbQg1usbAD0z9ONgpg/QbNHjwILiDa5y6FMn zGFwFUTaBUds/RIttqYMrQAIZvhgrKwlzexz+AlTlOgKy4G6L5co+PiFD55wuKsc2CyV PDILuQDxcvTq1L+tf1uwT359r4gAlXLxqYjbHxoK8UT1XkJfccOSqmoPXv5CNq+olhmo 02mt5kLhWcthGjkZfMSape/WDtdTCiMndqwwylaGMnzfV+UpPY9M0cO7EHRN8S9No0hD 8O8KV5xhQbuFJDZvGpm6KzUYhOIj4unHYdAL85bjL780qa8YGmjwYg1jCtbgdHRTsPu9 4KrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=V7trfwmfneYK4SSNw/SfOGj8r9QOI6ygQ5c1r2wUbls=; b=oGtIFPyPEhrW2X3fuLA1BlsciyH/Q7VLcAdDQr/VBKpi2y7Cr+B2nO0SyEc3PXV/WL IdIyKfO6vC55vWHHEMgSAaKU+2AXXt9YB1wHDpd2WjcNF9BGWWTfx0ymK5BifCYlMO7x w55W2yFZ5zkwNVIairD8NubZx+49yEq6hqDfqI9PALbkbiJQ7V3l1Er/txESJrvnZp/w sCc0HX27G4Jd3FaJqY/liM2DIsToZvQ74M6N0HV+EuaUY4owpinrewC+ASBQiY9ZONVD fLzMAGqYAG2v+aLnZLBu0eJgcrMZ8BX5JkG4EvCt3exiFcST8+0ldXs26nqYUtwhj0CD vBZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=GX6t7spD; 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 e33si967521pld.397.2019.01.05.15.19.03; Sat, 05 Jan 2019 15:19:20 -0800 (PST) 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=@linux-foundation.org header.s=google header.b=GX6t7spD; 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 S1726386AbfAEXQy (ORCPT + 99 others); Sat, 5 Jan 2019 18:16:54 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36397 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbfAEXQx (ORCPT ); Sat, 5 Jan 2019 18:16:53 -0500 Received: by mail-lj1-f195.google.com with SMTP id g11-v6so35234730ljk.3 for ; Sat, 05 Jan 2019 15:16:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=V7trfwmfneYK4SSNw/SfOGj8r9QOI6ygQ5c1r2wUbls=; b=GX6t7spD5TCxKk9/FB+FddDtgEmf/Maam6t7a9rOK2vbaIIrD7ipWwjLrJy7cSGVdH R+Qiu4e2Pu8D4WjZKvjAOeGOLZaOwd61Fj6waEP5yhL2Zf3+tKQ8S/xYB36PjA2OBYon MlgJzdnqL24g1b2TS29Yq2aY33fEwWDl2gHu8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V7trfwmfneYK4SSNw/SfOGj8r9QOI6ygQ5c1r2wUbls=; b=BkQ7ockpxSUY75oYzxXCY3a7A3lRmvyhHzBtRMH6CnUc+Bj64t30rEj2SXs+tQB3Z3 medHXomKDH+vTqiLWBRxwao5bar7d7Jn5zyY2Zv49+9W+ax9GaEHn/fLbfsd0hdp22Bi gxLArvp/oJ8EXmO/MRIJwQcTaIpxpXoB00gw5SGFMMt9KGfz1sLcAZbWYEyice9XKk+W FqC1FXsPlIg+fRy+uW10SoIV71pFBUwRyN/U9x+CYRdztGIK+zkYwOveXHIt+vMNTwsG tcAhGcdxYGMShd5OWj48ps7FRZv8o+Z93t0wfFQaq4Id2haDN5pn2olw2sqerojyO/8i tWLQ== X-Gm-Message-State: AJcUukd/zDMk1jkjw6Mdpg9ThjxTPyRuiW1VMwnEGjRdozNoHMTs5CxV djyM+91IS2Y9oLEHVHN9exexXKuMopo= X-Received: by 2002:a2e:5109:: with SMTP id f9-v6mr34304254ljb.52.1546730210786; Sat, 05 Jan 2019 15:16:50 -0800 (PST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id f20-v6sm13025233ljk.33.2019.01.05.15.16.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Jan 2019 15:16:48 -0800 (PST) Received: by mail-lf1-f48.google.com with SMTP id a8so2715818lfk.5 for ; Sat, 05 Jan 2019 15:16:48 -0800 (PST) X-Received: by 2002:a19:982:: with SMTP id 124mr26813387lfj.138.1546730208114; Sat, 05 Jan 2019 15:16:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Sat, 5 Jan 2019 15:16:32 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm/mincore: allow for making sys_mincore() privileged To: Jann Horn Cc: Jiri Kosina , Andrew Morton , Greg KH , Peter Zijlstra , Michal Hocko , Linux-MM , kernel list , Linux API Content-Type: multipart/mixed; boundary="0000000000009e74e7057ebe30b7" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000009e74e7057ebe30b7 Content-Type: text/plain; charset="UTF-8" On Sat, Jan 5, 2019 at 3:05 PM Linus Torvalds wrote: > > That would be nicer than my patch, simply because removing code is > always nice. And arguably it's a better semantic anyway. Yeah, I wonder why we did that thing where mincore() walks the page tables, but if they are empty it looks in the page cache. [... goes and looks in history ..] It goes back to forever, it looks like. I can't find a reason. Anyway, a removal patch would look something like the attached, I think. That makes mincore() actually say how many pages are in _this_ mapping, not how many pages could be paged in without doing IO. Hmm. Maybe we should try this first. Simplicity is always good. Again, obviously untested. Linus --0000000000009e74e7057ebe30b7 Content-Type: text/x-patch; charset="US-ASCII"; name="patch.diff" Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jqk37sgx0 IG1tL21pbmNvcmUuYyB8IDc0ICsrKysrLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLQogMSBmaWxlIGNoYW5nZWQsIDYgaW5zZXJ0aW9ucygrKSwg NjggZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEvbW0vbWluY29yZS5jIGIvbW0vbWluY29yZS5j CmluZGV4IDIxODA5OWI1ZWQzMS4uMzE3ZWI2NGVhNGVmIDEwMDY0NAotLS0gYS9tbS9taW5jb3Jl LmMKKysrIGIvbW0vbWluY29yZS5jCkBAIC00Miw2NCArNDIsMTIgQEAgc3RhdGljIGludCBtaW5j b3JlX2h1Z2V0bGIocHRl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