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=-13.1 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 6B506C433E1 for ; Wed, 24 Jun 2020 20:00:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E56D20CC7 for ; Wed, 24 Jun 2020 20:00:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gWs5urKS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406348AbgFXUAX (ORCPT ); Wed, 24 Jun 2020 16:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406241AbgFXUAW (ORCPT ); Wed, 24 Jun 2020 16:00:22 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF62C061795 for ; Wed, 24 Jun 2020 13:00:22 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id t6so1958337pgq.1 for ; Wed, 24 Jun 2020 13:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=5YurFeVtpOYVU5ydoL231turNTDylhl9IHjAbz77sBw=; b=gWs5urKSO+LqscynzsA4J+eqJDJAkH3tBkO/pG55Oc9LA2+QH7HzKz59mo7MeJjWuA mHV8ue/sZhEXa1URsrmDcDoWlOQRSTObJrJ0pUXY18bYxN+PqJxQSWojEHkKh+sSGm69 EpnYFjsRzGX8gaiG1z9pe3N+bBPuJP5/OeeS7Ur6RLDfJTaLz+4SA9lWHVsWESZFCUsk 2Aqv6L/ksmqQ4MyfazkqCWL3lrp+4rUF80zaLggi8eCSlY45LK3yu1rlIpP9+wOW3Sca oHUxUOXSRdfuxo6LwI8Y6WIfWvP9GbplTXykfwm1oHvDKeeqkJidgASklLocXHn4hIHh e3ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=5YurFeVtpOYVU5ydoL231turNTDylhl9IHjAbz77sBw=; b=rVzom+2aDhS977uzTutQt0cMWH79G3YwZ4+zJiHA8BNaUDoFHKksz9FnxKNA59dVN5 +iniSYnkPrCAPtsmJxDoZgA7OUfBNY8Oshtj5OFzQAseOys3NLqk9kcIOyk/VRAV6G4e zB0mFyBD9Rz5UZgKKlZTwsl+tPlSi9XxaMOGlLHmBItDeaJH4EDQmkfXUYjLr13ZEv8a yfPs2tZMxhkr+3SruEu6Q77GNYh1aw46zb+nFs5yBjjV8V75liJRjITemLj+rSFCVdQE sAHzwgHlc49WzP8C/KKhMIirQRKGe9QGDP1lP5jXqv4prpth13VAV9m0xGVPdUa1lrSF 0n2A== X-Gm-Message-State: AOAM533s+ktrstH3/C0mhYbvovwMe9vkjNBFWQBbfgNKyzhSydzirV/M sELqdA1oJRQebxTj2MlQWGgILA== X-Google-Smtp-Source: ABdhPJwtCEeKNEgeuOqiSzvg6ETq9Fn+Wg6Tlrq7FOjqG9WiTiT2/ej2Zy1HmHG3Cm5ZR+WRObO1PQ== X-Received: by 2002:aa7:8813:: with SMTP id c19mr32760795pfo.220.1593028821321; Wed, 24 Jun 2020 13:00:21 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id r7sm17649498pgu.51.2020.06.24.13.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 13:00:20 -0700 (PDT) Date: Wed, 24 Jun 2020 13:00:19 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Minchan Kim cc: Andrew Morton , LKML , Christian Brauner , linux-mm , linux-api@vger.kernel.org, oleksandr@redhat.com, Suren Baghdasaryan , Tim Murray , Sandeep Patil , Sonny Rao , Brian Geffon , Michal Hocko , Johannes Weiner , Shakeel Butt , John Dias , Joel Fernandes , Jann Horn , alexander.h.duyck@linux.intel.com, sj38.park@gmail.com, Arjun Roy , Vlastimil Babka , Jens Axboe , Daniel Colascione , Christian Brauner , Kirill Tkhai , SeongJae Park , linux-man@vger.kernel.org Subject: Re: [PATCH v8 1/4] mm/madvise: pass task and mm to do_madvise In-Reply-To: <20200622192900.22757-2-minchan@kernel.org> Message-ID: References: <20200622192900.22757-1-minchan@kernel.org> <20200622192900.22757-2-minchan@kernel.org> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-man-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-man@vger.kernel.org On Mon, 22 Jun 2020, Minchan Kim wrote: > Patch series "introduce memory hinting API for external process", v8. > > 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. > > This patch (of 4): > > In upcoming patches, do_madvise will be called from external process > context so we shouldn't asssume "current" is always hinted process's > task_struct. > > Furthermore, we must not access mm_struct via task->mm, but obtain it > via access_mm() once (in the following patch) and only use that pointer > [1], so pass it to do_madvise() as well. Note the vma->vm_mm pointers > are safe, so we can use them further down the call stack. > > And let's pass *current* and current->mm as arguments of do_madvise so > it shouldn't change existing behavior but prepare next patch to make > review easy. > > Note: io_madvise passes NULL as target_task argument of do_madvise because > it couldn't know who is target. > > [1] http://lore.kernel.org/r/CAG48ez27=pwm5m_N_988xT1huO7g7h6arTQL44zev6TD-h-7Tg@mail.gmail.com > > [vbabka@suse.cz: changelog tweak] > [minchan@kernel.org: use current->mm for io_uring] > Link: http://lkml.kernel.org/r/20200423145215.72666-1-minchan@kernel.org > [akpm@linux-foundation.org: fix it for upstream changes] > [akpm@linux-foundation.org: whoops] > [rdunlap@infradead.org: add missing includes] > Link: http://lkml.kernel.org/r/20200302193630.68771-2-minchan@kernel.org > Signed-off-by: Minchan Kim > Reviewed-by: Suren Baghdasaryan > Reviewed-by: Vlastimil Babka > Cc: Jens Axboe > Cc: Jann Horn > Cc: Tim Murray > Cc: Daniel Colascione > Cc: Sandeep Patil > Cc: Sonny Rao > Cc: Brian Geffon > Cc: Michal Hocko > Cc: Johannes Weiner > Cc: Shakeel Butt > Cc: John Dias > Cc: Joel Fernandes > Cc: Alexander Duyck > Cc: SeongJae Park > Cc: Christian Brauner > Cc: Kirill Tkhai > Cc: Oleksandr Natalenko > Cc: SeongJae Park > Cc: Christian Brauner > Cc: Acked-by: David Rientjes