Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4105017ima; Mon, 4 Feb 2019 10:16:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IZIuhQQ7PzoLXuZGQU7o4eWnqSunYct5uy6zrJQulCu6pQZBz2HjOEv8p4kOgL4uh/8aqKl X-Received: by 2002:a63:85c6:: with SMTP id u189mr621030pgd.156.1549304182194; Mon, 04 Feb 2019 10:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549304182; cv=none; d=google.com; s=arc-20160816; b=jMGjUvP72WqJbdUZiRaJ86Gzj05Xbzo9Us9F13f9GSkpaW9wd1u6QlfeQwliyzQPfQ Bgcq9SIIDZtsCwwI5CkfVbKYSkItnO9zcEGkj8h1gBiFtdf9zGt4te3B5kocifTpWK5g sGYVPe4a7tyJpIQHgyvHeAj9hVrzrd7oPRMayc6gypcKsrx2EPKlEog3FXrsCPfAFYCO X9VgLpomNctmtGtycm9eBGBTd32EAFxKjie8GJYDfWnsSb88Ux3QQ9gQ6vdzROYlrDr4 uu1zEHTiDqjp8tTHXi02p3gp+VYVFwqc6ddOGlgV6cZcUXRmdqbxStEJJ0A5meo/t4Wg 3iKw== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=zqElbD91wN7xrII3yrqdT2po60YKbiGuJ5EuHOboq08=; b=b47x4d2zkFkQc1XySpTRmnZXs2fidSNBVFpLkNbchKY0nQvZcktWieyjwXYfD0EHZZ sKrBqxy0EKwUfJt/vhgAUeUv92nzCrw5pB33oO/d+N45RVSibcZ8kaxI8cPkn24fkkmt J5GutwrGqWlv6QXSRXEXqb0FtcCzuteQV3Disb8N832LFFJ4WhUrjJKvTZZjMpmqj3c0 aLDaXqxL57PrlE/6LQHzHWre5bi7hEWQvi1z0R19FnaENmdGfYClSqIfMKsE5XXDuo47 ND/BHK9DoPiWKip0C9f1l1WchLsSzVDaLVjvG6r/p8tlM65kMkiOlSl2iWgvokOnaNth kFsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oJsYf7z3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si610764pga.349.2019.02.04.10.16.05; Mon, 04 Feb 2019 10:16:22 -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=@gmail.com header.s=20161025 header.b=oJsYf7z3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729378AbfBDSPn (ORCPT + 99 others); Mon, 4 Feb 2019 13:15:43 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:46864 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbfBDSPm (ORCPT ); Mon, 4 Feb 2019 13:15:42 -0500 Received: by mail-pg1-f195.google.com with SMTP id w7so251798pgp.13; Mon, 04 Feb 2019 10:15:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=zqElbD91wN7xrII3yrqdT2po60YKbiGuJ5EuHOboq08=; b=oJsYf7z38AP8TbCH80dOcCkJYlGDdhpEscQ3nBiPGAezSpQoznfn6yaatFIh56rLa3 WQTC59TkQ38+viuHQYO8ZTHXdI+ikg6haVJUBIfi65J1jh7YFOQScPeFfZn5FdLIwwV1 HQBqxVYcgT/LNtaebjn1fviZ+IgZBpZybIhLxGWy4QMZkk8/ERcgCeCm1h0Ahhp0HBSL ojLR6pytSqLpez0vfIpiHCesbcI1La8NGXWRe7x6NeiEsm8412Xo098elaZawQ0pGk05 5ytGec+2Ioqy0lGzOd4BXBHFOLC6p+IG7quU66Y9Uh+PJMntM5b7DnSKxSFW0Y1aRGXF smjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=zqElbD91wN7xrII3yrqdT2po60YKbiGuJ5EuHOboq08=; b=LXuOcFISuwC4gze3TDCTShTZFrOZVU+ZnCy1aNK0848sPWlZ0p9TPUr3/K/rVIEGTi tdL+kvNTZDkQ7xSxEb0oHB4u3A1fzfeoOjYzWv9lGW/1BeLXLqKdFnnCPbb1MxL79izm X5MxJTiMEh+ba+MjAcje2Kefr3f5V0Iy3mOVEnXfn9xR6A8rPSlMffYsNdSpe9J5O29H m35G0X2kuFkdC+YZFA+NavsjAhYFB+i7tuOErHgdGQIQRfiufp7+IApoEuoPQNctesCl dxjqIi0UzIH8ayYW4x2Qt7gWmMYl4as4cmgkclEHcjboS7HXhaVsAosJmBEmMrsyiQgS 6X8w== X-Gm-Message-State: AHQUAuaBssMwK/TvsA8m8S+hEizStvF1qetiRYuqZ1JKvh64FsM5HofK LpwZFW3/LUVdDGOCeDSIoHk= X-Received: by 2002:a63:2bc4:: with SMTP id r187mr615506pgr.306.1549304141567; Mon, 04 Feb 2019 10:15:41 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id v89sm1323954pfk.12.2019.02.04.10.15.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Feb 2019 10:15:41 -0800 (PST) Subject: [RFC PATCH 1/4] madvise: Expose ability to set dontneed from kernel From: Alexander Duyck To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: rkrcmar@redhat.com, alexander.h.duyck@linux.intel.com, x86@kernel.org, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, pbonzini@redhat.com, tglx@linutronix.de, akpm@linux-foundation.org Date: Mon, 04 Feb 2019 10:15:40 -0800 Message-ID: <20190204181540.12095.87973.stgit@localhost.localdomain> In-Reply-To: <20190204181118.12095.38300.stgit@localhost.localdomain> References: <20190204181118.12095.38300.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck In order to enable a KVM hypervisor to notify the host that a guest has freed its pages we will need to have a mechanism to update the virtual memory associated with the guest. In order to expose this functionality I am adding a new function do_madvise_dontneed that can be used to indicate a region that a given VM is done with. Signed-off-by: Alexander Duyck --- include/linux/mm.h | 2 ++ mm/madvise.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index e04396375cf9..eb668a5b4b4f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2840,5 +2840,7 @@ static inline bool page_is_guard(struct page *page) static inline void setup_nr_node_ids(void) {} #endif +int do_madvise_dontneed(unsigned long start, size_t len_in); + #endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */ diff --git a/mm/madvise.c b/mm/madvise.c index 21a7881a2db4..8730f7e0081a 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -799,7 +799,7 @@ static int madvise_inject_error(int behavior, * -EBADF - map exists, but area maps something that isn't a file. * -EAGAIN - a kernel resource was temporarily unavailable. */ -SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) +static int do_madvise(unsigned long start, size_t len_in, int behavior) { unsigned long end, tmp; struct vm_area_struct *vma, *prev; @@ -894,3 +894,14 @@ static int madvise_inject_error(int behavior, return error; } + +SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) +{ + return do_madvise(start, len_in, behavior); +} + +int do_madvise_dontneed(unsigned long start, size_t len_in) +{ + return do_madvise(start, len_in, MADV_DONTNEED); +} +EXPORT_SYMBOL_GPL(do_madvise_dontneed);