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=-18.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 69FF6C4338F for ; Wed, 4 Aug 2021 19:09:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E82E560F94 for ; Wed, 4 Aug 2021 19:09:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E82E560F94 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3D8FE8D0002; Wed, 4 Aug 2021 15:09:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3871F8D0001; Wed, 4 Aug 2021 15:09:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 250208D0002; Wed, 4 Aug 2021 15:09:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 0BDC18D0001 for ; Wed, 4 Aug 2021 15:09:02 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B70C0180AE7E2 for ; Wed, 4 Aug 2021 19:09:01 +0000 (UTC) X-FDA: 78438335682.10.7A5E192 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 6369F100CE9D for ; Wed, 4 Aug 2021 19:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628104140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MmgRMjocut7OSXdP14e4QYlZF0FOf7QmoFVYgj2gIC8=; b=DvahVTgvQN5K1PNnmljLjuqzPOt1Nva3nhROVdK5i5dXgNiyymkK0m8fYIr4vFFFyUnpWu GlOurKHvOyNZdOjBJs3LeXAp9qTzulefcpqUcxnsbz17s8S7C50BPUybpzjH3TpePBQxCH R0OHTARXcgdwmhgK+Nu918Gkkjg6t+Q= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-Kh0obJBSNrGVUNmp8Hxwbw-1; Wed, 04 Aug 2021 15:08:59 -0400 X-MC-Unique: Kh0obJBSNrGVUNmp8Hxwbw-1 Received: by mail-wr1-f72.google.com with SMTP id d13-20020adfc3cd0000b02901531b0b7c89so1154636wrg.23 for ; Wed, 04 Aug 2021 12:08:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=MmgRMjocut7OSXdP14e4QYlZF0FOf7QmoFVYgj2gIC8=; b=GYmvO5jMPB+GRO2JtDtGLPcUAttUxe4gwBp0E/aMJd+QEKYNZ7IuV5RnysG++mJU1p rrLiYdpKnOhXnUkVO4gnRj+XETy9KWYM6wT75RKrNqsv8S7cfwsAzSZF+nGO8OBzKlBc B517Yj1jEPEBaJqAlcfP5ddHs9DvikMbzT87bj6bUrs6l7onTKKaCscGeKjU85EeyqHk naP9GYpzpfSBZ5samBkUM1pOv0/jKdsD9Q3d2By6rtwkm7pPsJ18mIuGaDp3nVWSewzl rztEQcOg4R/AnSl2ssFlcH/lmQDWBdwExdcdep4Pnh7ayHLtI0UgMS2PkFYQeMZMqJpf LjOg== X-Gm-Message-State: AOAM530AwIsA+J7puMSlAzrg9fzfcs2yT9/2ftUOItwAk6HJY8gQC+8e m7nqi/7+EToBFL/Lq7UYIdKtE1dMv0YQqotu/74wYAZcTDYCvOe3AyRTuBZXtnMs5V2p/GozEFl NzPreppfiNMg= X-Received: by 2002:adf:cd02:: with SMTP id w2mr918138wrm.68.1628104138449; Wed, 04 Aug 2021 12:08:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr/wims9ZS/vrYwBXt5mU6isketLRTl4fzFijcJJ44MVzhRnRbQd+CgvmhYA6BR7DTxPpKxw== X-Received: by 2002:adf:cd02:: with SMTP id w2mr918126wrm.68.1628104138317; Wed, 04 Aug 2021 12:08:58 -0700 (PDT) Received: from [192.168.3.132] (p5b0c65d3.dip0.t-ipconnect.de. [91.12.101.211]) by smtp.gmail.com with ESMTPSA id y66sm3176625wmy.39.2021.08.04.12.08.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Aug 2021 12:08:57 -0700 (PDT) Subject: Re: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise() To: zhangkui , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210804082010.12482-1-zhangkui@oppo.com> From: David Hildenbrand Organization: Red Hat Message-ID: <480fd747-d8d7-0830-0b97-bf2069dbef07@redhat.com> Date: Wed, 4 Aug 2021 21:08:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210804082010.12482-1-zhangkui@oppo.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6369F100CE9D Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DvahVTgv; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf07.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: wwr5isi4pa9m5mhneee7iwe1hs5t9ubh X-HE-Tag: 1628104141-786660 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: On 04.08.21 10:20, zhangkui wrote: > 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, SMS can read-ahead memory of the process immediately > when the app switches to forground. > Calling process_madvise() with MADV_WILLNEED can meet this need. > > Signed-off-by: zhangkui > --- > mm/madvise.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/madvise.c b/mm/madvise.c > index 6d3d348b17f4..b9681fb3fbb5 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -1046,6 +1046,7 @@ process_madvise_behavior_valid(int behavior) > switch (behavior) { > case MADV_COLD: > case MADV_PAGEOUT: > + case MADV_WILLNEED: > return true; > default: > return false; I guess this should be fine. In contrast to other (e.g., destructive) madvise calls, an application could merely notice the difference that for example, in the pagemap something is suddenly no longer swapped, even thought the page wasn't touched by the process. But that can also happen e.g., during swapoff. So I think this is fine, but let's hear if there are concerns. -- Thanks, David / dhildenb