From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40610C33CB6 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 C63FB206E6 for ; Fri, 17 Jan 2020 00:00:04 +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 C63FB206E6 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) Received: by kanga.kvack.org (Postfix, from userid 40) id E516C6B0005; Thu, 16 Jan 2020 19:00:03 -0500 (EST) 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-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-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 Content-Transfer-Encoding: quoted-printable 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., ActivityMana= gerService), and that daemon must be able to initiate reclaim on its own without any a= pp 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 mome= nt. 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-minch= an@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(-) --=20 2.25.0.rc1.283.g88dfdc4193-goog