From patchwork Tue Jan 28 00:16:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11353383 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 6251B92A for ; Tue, 28 Jan 2020 00:16:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 25F8124656 for ; Tue, 28 Jan 2020 00:16:59 +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="Cm22HlzG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25F8124656 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 2A6EE6B0003; Mon, 27 Jan 2020 19:16:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 230396B0006; Mon, 27 Jan 2020 19:16:58 -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 0F9B16B0007; Mon, 27 Jan 2020 19:16:58 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id EB3856B0003 for ; Mon, 27 Jan 2020 19:16:57 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id B6D74180AD804 for ; Tue, 28 Jan 2020 00:16:57 +0000 (UTC) X-FDA: 76425127674.11.list02_59d19ebf8a001 X-Spam-Summary: 2,0,0,798bfabbaa925ebc,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:joel@joelfernandes.org:minchan@kernel.org,RULES_HIT:41:355:379:541:800:967:973:982:988:989:1260:1311:1314:1345:1437:1515:1535:1543:1711:1730:1747:1777:1792:1801:1981:2194:2198:2199:2200:2393:2525:2559:2564: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:13206:13229:13230:13894:14093:14096:14181:14394:14721: 21080:21 X-HE-Tag: list02_59d19ebf8a001 X-Filterd-Recvd-Size: 6601 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Jan 2020 00:16:57 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id r11so6022852pgf.1 for ; Mon, 27 Jan 2020 16:16:56 -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=Q/jjSPUmaGsjBw20OY6mWcuutvPTH8KThjAPA0mtHm0=; b=Cm22HlzGzxed4P0fYED+h/l3pX9ev8n9WlonJDZu+Q7a1oE88f85oqmD+g0YAhlCOf YtojffbsND2zff0tbZppj0oysT6WYjOih5tiXry1iF/lhycSUPCKO4jS4Aja6zdrbY4o mnwd4QSoN9u89cDwkVjR7G1++sAm+LByYQW18wCWAaWAk6wihiHvgCtUDMU7oBoZHN7s hQaXMP4iyjUhz9iwIYR8iwvbdJEBZyC4R3wd1/oLXkabCcSUYcug7akOmXD5BAo4Bh6A 2HVwdFA0VIKirJSeQdI3JsBkrrzi50rc9k6yewJbDyyPhMhcifARsbIvYbuS/gegK8Jp Lt8g== 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=Q/jjSPUmaGsjBw20OY6mWcuutvPTH8KThjAPA0mtHm0=; b=eG9ELIDO+6JP3aRPheJy8SEWNf+8mhr/aIhmQS9OFZ9MYbwinV7ZTcu5hcit+qSK88 1LFQ4XAICnz9CLNLrFpzJ8EQ8rs3dRiJ6nGIzT8U3yDe9npcYl6146vL/ysORJMYZ3Rq 8HValg9rXGPZX7DIKer90NgrHX2AK4/AKYSvsPivWmzw9k8OEPnNsPdubV9ft61Zjv89 9NylpomMSuE9sNwULXnTfy5QS3E8+lHY7hUOPhCOOShK2L/VelKk22gu1/M6nPsySJOG Ewwr2o5pNGOMGjiZZGj2PbuPNvAI3AnnOFyGDPbdyAP+5htqK7vDyy2WX3VNL2tPmUdk bmgw== X-Gm-Message-State: APjAAAXiW9WI1nWySApS/hQxAEfulyT9gLKe0X77smTZn8wLr1ZuKoCu tLJkFb/kW7Erh3a1E2/+HFA= X-Google-Smtp-Source: APXvYqwyqf8vB8GPhJHuK5cNfPp/zfDxvmYskudrPq/FRD83dQ6KmRUpgUdaFiG+Y+JR8z6f0C2gRQ== X-Received: by 2002:a63:5456:: with SMTP id e22mr21609620pgm.177.1580170615827; Mon, 27 Jan 2020 16:16:55 -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 q28sm11301461pfl.153.2020.01.27.16.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 16:16:54 -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 , Joel Fernandes , Minchan Kim Subject: [PATCH v3 0/5] introduce memory hinting API for external process Date: Mon, 27 Jan 2020 16:16:36 -0800 Message-Id: <20200128001641.5086-1-minchan@kernel.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-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. For more detail of the new API, please see "mm: introduce external memory hinting API" description in this patchset. 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 v2 - https://lore.kernel.org/linux-mm/20200116235953.163318-1-minchan@kernel.org/ * check signal callee and caller to bail out - Kirill Tkhai * put more clarification for justification of new API * from v1 - https://lore.kernel.org/linux-mm/20200110213433.94739-1-minchan@kernel.org/ * fix syscall number - SeongJae * use get_pid_task - Kirill Tkhai * extend API to support pid as well as pidfd - Kirill Tkhai 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 | 277 ++++++++++++++------ 24 files changed, 238 insertions(+), 102 deletions(-)