From patchwork Thu Jan 16 23:59:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11338029 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 E4F41921 for ; Fri, 17 Jan 2020 00:00:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9DA65206E6 for ; Fri, 17 Jan 2020 00:00:05 +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="F2v3toNY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DA65206E6 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 599CB6B0003; Thu, 16 Jan 2020 19:00:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E516C6B0005; Thu, 16 Jan 2020 19:00:03 -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 3750F6B0006; Thu, 16 Jan 2020 19:00:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id C01B56B0003 for ; Thu, 16 Jan 2020 19:00:00 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 6927245DA for ; Fri, 17 Jan 2020 00:00:00 +0000 (UTC) X-FDA: 76385168160.24.stew68_1d16168efe924 X-Spam-Summary: 2,0,0,1923151495985ff5,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:ktkhai@virtuozzo.com:christian.brauner@ubuntu.com:sjpark@amazon.de:minchan@kernel.org,RULES_HIT:41:355:379:541:800:967:973:988:989:1260:1311:1314:1345:1437:1515:1535:1542:1711:1730:1747:1777:1792:1801:1981:2194:2198:2199:2200:2393:2525:2559:2563:2682:2685:2693:2859:2892:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4250:4321:4605:5007:6119:6261:6653:6742:7875:8957:9025:10004:10226:11026:11657:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13053:13141:13230:13894:14 096:1418 X-HE-Tag: stew68_1d16168efe924 X-Filterd-Recvd-Size: 6295 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 23:59:59 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id a6so2333765pjh.2 for ; Thu, 16 Jan 2020 15:59:59 -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=CzG/+enlCQzh2PEldVrxjNnE7U+SNtVgOSzvdsBcADU=; b=F2v3toNYnfFqQUyw6x3N7//SMHYRN13v+ZPOldYSLqV8UY6+AqK4DbYydfN+CoN8IG qLLk8Hvd5Bc1SJRAPeCEUhrx7S4kBmD07wkCZmf823GUc29l2mclHI74aRm3A9goTScp cAM6sOkPe0No97IBxVY5eQRXuIBBS9DJs9Jy7+DwILntGzBKiXorrJ//oXbz1EdESaEZ Zte5orRtIvXG0nF64FI9Zbbg9ue+7spGSQBOl10VarQFuM6pIV5YUpZQ/0n5xW15GUCS SO96RLVB1fQuVVVnnmIzaubOo/K1TS65Yn/qYqx6qmGzqD1swf8G/MQNGlbaXJV5Jaoi Ajuw== 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=CzG/+enlCQzh2PEldVrxjNnE7U+SNtVgOSzvdsBcADU=; b=XYbPm+0kvJ+1DRD+noW1A2aMG1dTHhwZTQbg0m7Fbj4QzN94RKers+nXVYPSN6Orho 4tzd28hvRDm4Cjg8iCa7J1TxS7eopPdin3XEEXxTI1F7vE3q2vA/VxLSOJxUf4DwHAP/ FWLFT62O2ogU0q4Hwy6fvqv6pw+NdUkfOWCwkgFP490F9KEEyo6tMyEQUP2Kpp3xMxoD bve+aLAjMuFiTE+sRo4L+n2U/m5/ba7q8Jm+3XGpZw3VRgg61MLQYvaK0oOLxbkP/bPc I9Tz5ilLN+zzqhRoUXSpKCVNIntpi0yrAewas8qpFoqHRzkYfr31PBXq7msoyia25P4B IeqQ== X-Gm-Message-State: APjAAAWQAni5l7lYj5kgjXzVy3j3CXc6tiJSKl1bvY0aWUstXGXsacst rk6SHe2CGOwTDqvmt7PPv5k= X-Google-Smtp-Source: APXvYqwlhvXUMP4R0TTP6WlHVKFM1ZuAfuosRyTmmZybSE+cUdmVz7aTgL+1O3XlksiaTb8C3G0UWA== X-Received: by 2002:a17:90a:db0b:: with SMTP id g11mr2231520pjv.140.1579219198676; Thu, 16 Jan 2020 15:59:58 -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 z4sm26584885pfn.42.2020.01.16.15.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 15:59:57 -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 , ktkhai@virtuozzo.com, christian.brauner@ubuntu.com, sjpark@amazon.de, Minchan Kim Subject: [PATCH v2 0/5] introduce memory hinting API for external process Date: Thu, 16 Jan 2020 15:59:48 -0800 Message-Id: <20200116235953.163318-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 (3): mm: factor out madvise's core functionality mm: introduce external memory hinting API mm: support both pid and pidfd for process_madvise Oleksandr Natalenko (2): mm/madvise: employ mmget_still_valid for write lock mm/madvise: allow KSM hints for remote API * from v1 - https://lore.kernel.org/linux-mm/20200110213433.94739-1-minchan@kernel.org/ * fix syscall number - SeongJae * use get_pid_task - Kirill * extend API to support pid as well as pidfd - Kirill 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/pid.h | 1 + include/linux/syscalls.h | 3 + include/uapi/asm-generic/unistd.h | 5 +- kernel/exit.c | 17 -- kernel/pid.c | 17 ++ kernel/sys_ni.c | 1 + mm/madvise.c | 272 ++++++++++++++------ 24 files changed, 233 insertions(+), 102 deletions(-)