From patchwork Thu Sep 2 22:01:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12473251 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 7113EC433FE for ; Thu, 2 Sep 2021 22:01:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 427DE60724 for ; Thu, 2 Sep 2021 22:01:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 427DE60724 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id DE050940019; Thu, 2 Sep 2021 18:01:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F4F994001E; Thu, 2 Sep 2021 18:01:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BAC394001A; Thu, 2 Sep 2021 18:01:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 7D26B94001E for ; Thu, 2 Sep 2021 18:01:17 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3FE1F183B30D1 for ; Thu, 2 Sep 2021 22:01:17 +0000 (UTC) X-FDA: 78544004994.23.888FC18 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf24.hostedemail.com (Postfix) with ESMTP id 05765B000819 for ; Thu, 2 Sep 2021 22:01:16 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 0D3FA610E7; Thu, 2 Sep 2021 22:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1630620072; bh=SzvW1FD9Z7jDJpbupNPxlIQPOeZubWgjw+Wut/pl9bs=; h=Date:From:To:Subject:In-Reply-To:From; b=clGKx0U0ylEgvZDWw6j1ue0B0mleLP8qVhAhDKrDAL1PZdNRS/K8NgtnDAK8PuV7b UJEplt6E6i42Ng0s5bwgndX8kWIboU59p1x/V5cpxCBysKcAqosA6h2WQaCrU874wl XWGSGbQXTCyYpRa1MRrtkWIutqpGjGsSudQOutCI= Date: Thu, 02 Sep 2021 15:01:11 -0700 From: Andrew Morton To: akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, zhangkui@oppo.com Subject: [patch 212/212] mm/madvise: add MADV_WILLNEED to process_madvise() Message-ID: <20210902220111.lorKCcIsp%akpm@linux-foundation.org> In-Reply-To: <20210902144820.78957dff93d7bea620d55a89@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=clGKx0U0; spf=pass (imf24.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 05765B000819 X-Stat-Signature: 6ohecwd3913ry4r9nqcfkw73x5ctijy7 X-HE-Tag: 1630620076-955634 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: From: zhangkui Subject: mm/madvise: add MADV_WILLNEED to process_madvise() There is a usecase in Android that an app process's memory is swapped out by process_madvise() with MADV_PAGEOUT, such as the memory is swapped to zram or a backing device. When the process is scheduled to running, like switch to foreground, multiple page faults may cause the app dropped frames. To reduce the problem, System Management Software can read-ahead memory of the process immediately when the app switches to forground. Calling process_madvise() with MADV_WILLNEED can meet this need. Link: https://lkml.kernel.org/r/20210804082010.12482-1-zhangkui@oppo.com Signed-off-by: zhangkui Cc: David Hildenbrand Signed-off-by: Andrew Morton --- mm/madvise.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/madvise.c~mm-madvise-add-madv_willneed-to-process_madvise +++ a/mm/madvise.c @@ -1048,6 +1048,7 @@ process_madvise_behavior_valid(int behav switch (behavior) { case MADV_COLD: case MADV_PAGEOUT: + case MADV_WILLNEED: return true; default: return false;