Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp856806ybt; Wed, 24 Jun 2020 13:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFblm0K13RGHBA9Pv35XuZPHa3IJgsYEQYCYuq0n3TEr/sv/R6ujCIFjP+rvIH1ZLyqecj X-Received: by 2002:a50:8425:: with SMTP id 34mr29000841edp.314.1593028873152; Wed, 24 Jun 2020 13:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593028873; cv=none; d=google.com; s=arc-20160816; b=xDTJdC6NuZ4BAvvakNazTItHBLW7/ku+3BOVnVGmZx/85cuHALPGrxdRi33VTN7GNJ gMkD3xBFmgcY0xO5qYP+TnyVLpzg50uyEFyZfgfD+VxMT7ga+JEYk5j+1IUsPrRs6v5W N5AvEaEriqt7STEVOIEIx0Jj9JNtgNRcCf95EqIhgS8xa+iwsnaWZQmYXeoeBCzigUi/ z+vSbxB6KLpeeOAHDiDaIXvK6VMZkcCpENTNC2tTSgcXIW5Wn2q3SHbFa4edaX00xvvC d29UzvRXIcCi9RdpJeuIVkOHwJFRjnkyXBEshuWh+Qj5A293eL4Nj5kWaxsNb1HfOrFk LEDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=5YurFeVtpOYVU5ydoL231turNTDylhl9IHjAbz77sBw=; b=Z1bXlUQYyZRfppJ3Z2gTUM8RWaRsBoA0t2qRZFZC70/iIRYlJq+t1cBRVzISIEVs5M u39tK51Iy3Odbdj4GA+//pR0V6j6RTIY+8bzakmiPRm5EChonsrI0no/2g1fV0FV1a56 D4wb0K6oXBsWi+ZhoXu6BpUg/ezPRCiLWO13n91Zea8Fo6zrKmczKHC9v6jj9r6eqsBP 4X4YAfwMIM3UFzGAsf/n1AbnvLiVkEazsI9WDkuNrQFzTY4/k5KrWacLywgMNQowA6Og sjpSRSXgHB2wesBOhZspohApw2/SbQXideejGGqGi9XGduasR7Cpt/q16/merz1k3ZoJ x/xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gWs5urKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si13262011ejn.265.2020.06.24.13.00.48; Wed, 24 Jun 2020 13:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gWs5urKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406241AbgFXUAX (ORCPT + 99 others); Wed, 24 Jun 2020 16:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406231AbgFXUAW (ORCPT ); Wed, 24 Jun 2020 16:00:22 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ACB2C061573 for ; Wed, 24 Jun 2020 13:00:22 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id f3so1956326pgr.2 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=SBEdEbBJpc0LR474N1jM+rjIrwGmPcadA2fKTPBcRypyOCdStzKyY3UazOZ9sOvq9n OWWxt0HEEZhTJjYRXxXvoFTf83B1C+lokeYZnKgeGkKimYFUNhGybTekEBUGmCgzBntO NJXks4aWM6eH0qzQ+DsO8O2QMr0g71pydIJKr+Sfe+cutSWJavAC06U9CAL0N03PTFd3 8zWfVHz6s9Osi1fzrO37bs/t5nIKSI9IVVvdTP9xQf6pUaD1z762koaBqfwe1dCIqnUX cNY4py2IrjrT5cqwljJ9muznRCLGbMMx4a81JwQrbfhqBRpNDmfCjhOLnuP7FNYFIK84 Y2NQ== X-Gm-Message-State: AOAM533SYz545QcdbM6ddLC4wGGDaYeKGHIdeZwQOJBJcZ31blwbuXvZ 82Agx6D4weAnF21ExLpk2Kufsg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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