From patchwork Fri Jan 10 21:34:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11328481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61FB5921 for ; Fri, 10 Jan 2020 21:34:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 11A4E20880 for ; Fri, 10 Jan 2020 21:34:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ysp3fcGZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11A4E20880 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 58FCF8E0005; Fri, 10 Jan 2020 16:34:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 51A298E0001; Fri, 10 Jan 2020 16:34:40 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E1898E0005; Fri, 10 Jan 2020 16:34:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id 247348E0001 for ; Fri, 10 Jan 2020 16:34:40 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id C506E8248D7C for ; Fri, 10 Jan 2020 21:34:39 +0000 (UTC) X-FDA: 76363029078.08.seed54_b8ba1f7f3d4a X-Spam-Summary: 2,0,0,7b4c511d2472d310,d41d8cd98f00b204,minchan.kim@gmail.com,:akpm@linux-foundation.org:linux-kernel@vger.kernel.org::linux-api@vger.kernel.org:oleksandr@redhat.com:surenb@google.com:timmurray@google.com:dancol@google.com:sspatil@google.com:sonnyrao@google.com:bgeffon@google.com:mhocko@suse.com:hannes@cmpxchg.org:shakeelb@google.com:joaodias@google.com:minchan@kernel.org,RULES_HIT:41:355:379:541:973:988:989:1260:1311:1314:1345:1437:1515:1535:1542:1711:1730:1747:1777:1792:1801:1981:2194:2198:2199:2200:2393:2559:2562:2693:2892:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4250:4605:5007:6119:6261:6653:6742:7875:8784:8957:10004:10226:11026:11657:11658:11914:12043:12296:12297:12438:12517:12519:12679:12895:13053:13141:13230:13894:14096:14181:14394:14721:21080:21433:21444:21451:21627:30003:30054:30075,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,M SF:not b X-HE-Tag: seed54_b8ba1f7f3d4a X-Filterd-Recvd-Size: 5784 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jan 2020 21:34:39 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id s64so1572271pgb.9 for ; Fri, 10 Jan 2020 13:34:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kUxvkA/9wBEhfF4c0Ct5r0wRWCEBzV0f25SyUAAjvzQ=; b=Ysp3fcGZ5hTzZMkrpsarvwMsGJeWWUxqKFw0tO8sE+eOKLDBShkkvEo5ksv7WIJjfu U4DXzuq2MGcxaDZ1TWoEfIJx6xtxles0BkiWMEraZVR0iti5nYCd15SmFBPt5SBwKb3h EVNA+zdD8XN3KaHinsDhLVDT9DCPrcrXEbFc9uirjDf3851eDnp8874XUwC5m/CuOJ4d L/RV4hNQB5k/+DI7EZ69gRmZql6dFK43gDmTPbfbJWmQetNrGkIJJvbMHe55EdnYlCmT xSySiRihDqmJfiDkCbW1LxLed06ZW21aPe1FUANQyy3pcQoCHrNYPNd7wDqDRD6egZ0a ZShA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=kUxvkA/9wBEhfF4c0Ct5r0wRWCEBzV0f25SyUAAjvzQ=; b=tXXp3UpOg12V5tISn7pHoV2GxZXf/YplHdtIBv2RTCcyD4BhEtbBzVZMxchnPT1P5P qxcsQeEHW16Rh+ylFLjyRjqOf1gv/8Xp5l4SZZGCUHn7lR7ezBeMJ9HAnpzkRmwlb6x2 Iu0LQB9yP1HerECBUQgrUInwGqoHe0pPqibzkXehAdNkJ0H0sFyx3KwbBeyaL43eRL4W oKcrKOt9nzJbzRuqys6IpDbdl2nynOtmlC6Uw1YHdyuUY7o5NG/5kuKNzvvp5Zc9EOaR xxe68yPB3v2+LMw+LzTV/Y83R1yoiXu2scnRbiujNPSHEZs/BC8Tj16Rgftqr2LVl84o 1+Og== X-Gm-Message-State: APjAAAWuMZmrYlKEm60oxw8C7EfVOe+iTjrm4swn2K70NgVxrVqZUw7X gWHJSPGJIubb+NuSWrYs9Ag= X-Google-Smtp-Source: APXvYqxARsDrk+ixhGWJoPkKby6xFB+IlE0oFwuWc/PMGRgL/6mrQg84c+egjiIFNPaOAzor8ns0Pg== X-Received: by 2002:aa7:928b:: with SMTP id j11mr6465632pfa.176.1578692078184; Fri, 10 Jan 2020 13:34:38 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id t137sm3692307pgb.40.2020.01.10.13.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2020 13:34:37 -0800 (PST) From: Minchan Kim To: Andrew Morton Cc: LKML , linux-mm , linux-api@vger.kernel.org, oleksandr@redhat.com, Suren Baghdasaryan , Tim Murray , Daniel Colascione , Sandeep Patil , Sonny Rao , Brian Geffon , Michal Hocko , Johannes Weiner , Shakeel Butt , John Dias , Minchan Kim Subject: [PATCH 0/4] introduce memory hinting API for external process Date: Fri, 10 Jan 2020 13:34:29 -0800 Message-Id: <20200110213433.94739-1-minchan@kernel.org> X-Mailer: git-send-email 2.25.0.rc1.283.g88dfdc4193-goog MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now, we have MADV_PAGEOUT and MADV_COLD as madvise hinting API. With that, application could give hints to kernel what memory range are preferred to be reclaimed. However, in some platform(e.g., Android), the information required to make the hinting decision is not known to the app. Instead, it is known to a centralized userspace daemon(e.g., ActivityManagerService), and that daemon must be able to initiate reclaim on its own without any app involvement. To solve the concern, this patch introduces new syscall - process_madvise(2). Bascially, it's same with madvise(2) syscall but it has some differences. 1. It needs pidfd of target process to provide the hint 2. It supports only MADV_{COLD|PAGEOUT|MERGEABLE|UNMEREABLE} at this moment. Other hints in madvise will be opened when there are explicit requests from community to prevent unexpected bugs we couldn't support. 3. Only privileged processes can do something for other process's address space. Minchan Kim (2): mm: factor out madvise's core functionality mm: introduce external memory hinting API Oleksandr Natalenko (2): mm/madvise: employ mmget_still_valid for write lock mm/madvise: allow KSM hints for remote API arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd.h | 2 +- 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/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 + include/linux/syscalls.h | 2 + include/uapi/asm-generic/unistd.h | 5 +- kernel/sys_ni.c | 1 + mm/madvise.c | 263 ++++++++++++++------ 21 files changed, 205 insertions(+), 85 deletions(-)