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=-11.4 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,USER_IN_DEF_DKIM_WL autolearn=no 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 D0812C11D20 for ; Thu, 20 Feb 2020 21:15:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2AB5206F4 for ; Thu, 20 Feb 2020 21:15:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="itJvvjLT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729027AbgBTVPS (ORCPT ); Thu, 20 Feb 2020 16:15:18 -0500 Received: from mail-vk1-f196.google.com ([209.85.221.196]:37659 "EHLO mail-vk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgBTVPS (ORCPT ); Thu, 20 Feb 2020 16:15:18 -0500 Received: by mail-vk1-f196.google.com with SMTP id b2so1625252vkk.4 for ; Thu, 20 Feb 2020 13:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=itJvvjLTjnAztaW3ELzLWWOItRSpx0VEbznSWQRD2w5LWICCqXBPNEHhDU5rFKFP6Q vuyEYtotOdCIFIz1XJec20kXLy25/JiQ6uw+0bgl/zEfBCQyL6qIxrsqZdnFBw+0pOa6 dhuSeGnzbUKkl20/CUxAFyxo57oxShrr081lqlT55iOBkdQo+UkLgySNpVO0kGfAe3h5 PMbTsKhsLUG0Oh3M0J9t4j+UdalOyoi/arcDlydpv0KIHUjajmBRd+IRjc3Ds7lsHaBK OQOIgksxwxaYbkPodvrysTB+g9laG5Peu7Mo06tw+vP91Kj31rabF/tyoXRamNVQmH2F 8CTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=RsXdqo5XD+16CNrPrJNFSLsEPplFBfYTFZkUTgdXc6W//jImrzeCmSuqBkypwJhQaM 8NxtUi+iPI+a7yAdAUf4ykb9A+whK9CJRlg1YMfb1jjNVTwZqL6GEO+zCLX/BFkQ71Lp CfPsMUmtldQ8y8pe8qsWPax+8IrLBYxSTYz+yGXR1KgilT1CrsaepAKSWSxVI4HyR/Fg 9O3nFbGotvhzK2z3FANzqGbsjiXPeTY/og2JtL16c9WoeWferRAnb0rR81C9FjHe2NUg n1VDiGeQF7QjDGQlqDJl0IY97L/rHKEWrrIKUdzUXRXdyRjwAAbtiaU3fy3dzNNhNznI qpXQ== X-Gm-Message-State: APjAAAUb7bx7W2DgC6vL8PP+tg7OkbDzlMX0kSj5a0XgIUzVCKWNybrJ mhqBhLyiYQ4Ocudaxg0WecTXnJAkhb7Q4p7WQa0gQA== X-Google-Smtp-Source: APXvYqyCkkbwdY7/IDGLKw691E2mNt/d2lLCEjoEG68m8sSXMR34k1Di0Rm7ufY66/tPsJ4DsT/vqWsRb+qu0brj+04= X-Received: by 2002:a1f:ee45:: with SMTP id m66mr15468181vkh.75.1582233316395; Thu, 20 Feb 2020 13:15:16 -0800 (PST) MIME-Version: 1.0 References: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> In-Reply-To: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> From: Shakeel Butt Date: Thu, 20 Feb 2020 13:15:05 -0800 Message-ID: Subject: Re: [PATCH v3 2/3] mm: Charge active memcg when no mm is set To: Dan Schatzberg Cc: Jens Axboe , Tejun Heo , Li Zefan , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Hugh Dickins , Roman Gushchin , Chris Down , Yang Shi , Thomas Gleixner , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" Content-Type: text/plain; charset="UTF-8" Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Thu, Feb 20, 2020 at 8:52 AM Dan Schatzberg wrote: > > memalloc_use_memcg() worked for kernel allocations but was silently > ignored for user pages. > > This patch establishes a precedence order for who gets charged: > > 1. If there is a memcg associated with the page already, that memcg is > charged. This happens during swapin. > > 2. If an explicit mm is passed, mm->memcg is charged. This happens > during page faults, which can be triggered in remote VMs (eg gup). > > 3. Otherwise consult the current process context. If it has configured > a current->active_memcg, use that. Otherwise, current->mm->memcg. > > Previously, if a NULL mm was passed to mem_cgroup_try_charge (case 3) it > would always charge the root cgroup. Now it looks up the current > active_memcg first (falling back to charging the root cgroup if not > set). > > Signed-off-by: Dan Schatzberg > Acked-by: Johannes Weiner > Acked-by: Tejun Heo Reviewed-by: Shakeel Butt 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=-11.4 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,USER_IN_DEF_DKIM_WL autolearn=no 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 BEE2EC11D25 for ; Thu, 20 Feb 2020 21:15:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7EBC820679 for ; Thu, 20 Feb 2020 21:15:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="itJvvjLT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EBC820679 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A6416B0007; Thu, 20 Feb 2020 16:15:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 208DA6B0008; Thu, 20 Feb 2020 16:15:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F6586B000A; Thu, 20 Feb 2020 16:15:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id EDDF76B0007 for ; Thu, 20 Feb 2020 16:15:17 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B3A132C9D for ; Thu, 20 Feb 2020 21:15:17 +0000 (UTC) X-FDA: 76511761074.08.yard00_2e2f7dd4c871d X-HE-Tag: yard00_2e2f7dd4c871d X-Filterd-Recvd-Size: 4412 Received: from mail-vk1-f196.google.com (mail-vk1-f196.google.com [209.85.221.196]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 21:15:17 +0000 (UTC) Received: by mail-vk1-f196.google.com with SMTP id m195so1603495vkh.10 for ; Thu, 20 Feb 2020 13:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=itJvvjLTjnAztaW3ELzLWWOItRSpx0VEbznSWQRD2w5LWICCqXBPNEHhDU5rFKFP6Q vuyEYtotOdCIFIz1XJec20kXLy25/JiQ6uw+0bgl/zEfBCQyL6qIxrsqZdnFBw+0pOa6 dhuSeGnzbUKkl20/CUxAFyxo57oxShrr081lqlT55iOBkdQo+UkLgySNpVO0kGfAe3h5 PMbTsKhsLUG0Oh3M0J9t4j+UdalOyoi/arcDlydpv0KIHUjajmBRd+IRjc3Ds7lsHaBK OQOIgksxwxaYbkPodvrysTB+g9laG5Peu7Mo06tw+vP91Kj31rabF/tyoXRamNVQmH2F 8CTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=ePr2UFPa4GEd357Q9BXiobfYh70TiHrHmEfX1Z6bSRE1hZ/42TRiKCoh0X+DrM9+kc zXUowrlWuNGShoOjU6rmOj6MkaCSQ1vmbZsKNqtFR0BtvoHLVrAvfLfKcZGuNvXrtO6c 2BkmzAoE7+meXUzU1EYZXsCPIsKrHvBBXhmciuW8O+IoHpR/T3xc30b4DFVS9FmA9iJM YD1SxUf+3J7aAcFnbQtuEy1ta+zycgioghcq5LnA/fClwE8tTkzHg/RrAdghAKF9mb+P BgOh0qcQS1tXI7W/Qh6gCgV2zj5rE7JTAbTbm5MDjrR762qmAQ/9vT0Jdew6LPdegGdt opwg== X-Gm-Message-State: APjAAAWVhEQpwbcUt3j2uL/Y1V5phZlBYxJJ8tZReFZkuHqjWDQOwFMp Q4JinyvRF7CtZD8V8ipAQZU4XAl9cYiygu3UJWZtXA== X-Google-Smtp-Source: APXvYqyCkkbwdY7/IDGLKw691E2mNt/d2lLCEjoEG68m8sSXMR34k1Di0Rm7ufY66/tPsJ4DsT/vqWsRb+qu0brj+04= X-Received: by 2002:a1f:ee45:: with SMTP id m66mr15468181vkh.75.1582233316395; Thu, 20 Feb 2020 13:15:16 -0800 (PST) MIME-Version: 1.0 References: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> In-Reply-To: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> From: Shakeel Butt Date: Thu, 20 Feb 2020 13:15:05 -0800 Message-ID: Subject: Re: [PATCH v3 2/3] mm: Charge active memcg when no mm is set To: Dan Schatzberg Cc: Jens Axboe , Tejun Heo , Li Zefan , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Hugh Dickins , Roman Gushchin , Chris Down , Yang Shi , Thomas Gleixner , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" Content-Type: text/plain; charset="UTF-8" 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 Thu, Feb 20, 2020 at 8:52 AM Dan Schatzberg wrote: > > memalloc_use_memcg() worked for kernel allocations but was silently > ignored for user pages. > > This patch establishes a precedence order for who gets charged: > > 1. If there is a memcg associated with the page already, that memcg is > charged. This happens during swapin. > > 2. If an explicit mm is passed, mm->memcg is charged. This happens > during page faults, which can be triggered in remote VMs (eg gup). > > 3. Otherwise consult the current process context. If it has configured > a current->active_memcg, use that. Otherwise, current->mm->memcg. > > Previously, if a NULL mm was passed to mem_cgroup_try_charge (case 3) it > would always charge the root cgroup. Now it looks up the current > active_memcg first (falling back to charging the root cgroup if not > set). > > Signed-off-by: Dan Schatzberg > Acked-by: Johannes Weiner > Acked-by: Tejun Heo Reviewed-by: Shakeel Butt From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shakeel Butt Subject: Re: [PATCH v3 2/3] mm: Charge active memcg when no mm is set Date: Thu, 20 Feb 2020 13:15:05 -0800 Message-ID: References: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=itJvvjLTjnAztaW3ELzLWWOItRSpx0VEbznSWQRD2w5LWICCqXBPNEHhDU5rFKFP6Q vuyEYtotOdCIFIz1XJec20kXLy25/JiQ6uw+0bgl/zEfBCQyL6qIxrsqZdnFBw+0pOa6 dhuSeGnzbUKkl20/CUxAFyxo57oxShrr081lqlT55iOBkdQo+UkLgySNpVO0kGfAe3h5 PMbTsKhsLUG0Oh3M0J9t4j+UdalOyoi/arcDlydpv0KIHUjajmBRd+IRjc3Ds7lsHaBK OQOIgksxwxaYbkPodvrysTB+g9laG5Peu7Mo06tw+vP91Kj31rabF/tyoXRamNVQmH2F 8CTg== In-Reply-To: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dan Schatzberg Cc: Jens Axboe , Tejun Heo , Li Zefan , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Hugh Dickins , Roman Gushchin , Chris Down , Yang Shi , Thomas Gleixner , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" On Thu, Feb 20, 2020 at 8:52 AM Dan Schatzberg wrote: > > memalloc_use_memcg() worked for kernel allocations but was silently > ignored for user pages. > > This patch establishes a precedence order for who gets charged: > > 1. If there is a memcg associated with the page already, that memcg is > charged. This happens during swapin. > > 2. If an explicit mm is passed, mm->memcg is charged. This happens > during page faults, which can be triggered in remote VMs (eg gup). > > 3. Otherwise consult the current process context. If it has configured > a current->active_memcg, use that. Otherwise, current->mm->memcg. > > Previously, if a NULL mm was passed to mem_cgroup_try_charge (case 3) it > would always charge the root cgroup. Now it looks up the current > active_memcg first (falling back to charging the root cgroup if not > set). > > Signed-off-by: Dan Schatzberg > Acked-by: Johannes Weiner > Acked-by: Tejun Heo Reviewed-by: Shakeel Butt