lkml.org 
[lkml]   [2019]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[RFC PATCH 1/4] madvise: Expose ability to set dontneed from kernel
    From
    Date
    From: Alexander Duyck <alexander.h.duyck@linux.intel.com>

    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 <alexander.h.duyck@linux.intel.com>
    ---
    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);
    \
     
     \ /
      Last update: 2019-02-04 19:16    [W:4.071 / U:0.088 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site