Received: by 10.223.185.116 with SMTP id b49csp1047240wrg; Wed, 21 Feb 2018 11:09:17 -0800 (PST) X-Google-Smtp-Source: AH8x226tXlHEIGPQJ17ALLPhQCXBfg5+RQOZWMM/LX70wXf+Xu2V6kN7JMqpzizNRD/RJ63d4ziq X-Received: by 10.98.112.70 with SMTP id l67mr4266811pfc.196.1519240157516; Wed, 21 Feb 2018 11:09:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519240157; cv=none; d=google.com; s=arc-20160816; b=jHcxUoUAiWOR8/HTIyE1ATPM5k8Sr3wg87+z/mZanhCKw1LAGjqtJtE7HgaNavhN89 Od0ZO9CLSvUn0gk/Uw+rFh6rz9uCi+zfYcsakXhEzXMjk/fTArcK5nOox+wWlB75kXPp DKFMz8MTBOsRzsKotBXDm73T2MzFn+mfYuds4dGEk8tcKgKODS5OtxZRHOajROFyTgH3 Sajki8bkIdgpk58LSAqBzYbuPlsqr5I2mh1haxSKoH7yU/PDmkwOcDKxSOTlCS3GNzph l3fMkg1XQm2SR5GoqJLfNhMXdsA3VUbzQJGEvBTNcLCwNZDROsjYFyrdl0G4e0vgDfbg ODIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=TilM8cwD1XtU9mVpUnbiFz6uKljbIimEdcUk3gb5jRk=; b=DjU+U9LeFvEUtMXcKfJyBUMpc7a8oAT2fljXWMKOR1t2AEP8pKTtv8UQ8kDHVpLm9C yiuBaubZJilHmulPUNQnRUAYAUSQcE33nP1NNwvSFwYe/uELR5elHHbbGYYEhU1pKwIx 4H5lh3uAD1A7hddHoyDhUC0heszyPzGJfXcmIqbnRHv/uPJpxYNJOSNLBIwToTiPjAvw WF40z9/SBKTAdoM8Uib6N6pixDOAr/9gSSzP1GaSmlLgNxMWSEQAaCcXE6HUbDhAJDv1 iRxKLEKUju9biI6bKT4PTOwI3xfpfpC/BoTdw6RzBhgO/EGfp8Tqdv41wcRRPSaLGjXa rFPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PcSycXrs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id e91-v6si7440309plb.177.2018.02.21.11.09.03; Wed, 21 Feb 2018 11:09:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PcSycXrs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S934071AbeBURSm (ORCPT + 99 others); Wed, 21 Feb 2018 12:18:42 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:39661 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934022AbeBURSi (ORCPT ); Wed, 21 Feb 2018 12:18:38 -0500 Received: by mail-wr0-f195.google.com with SMTP id w77so6603011wrc.6 for ; Wed, 21 Feb 2018 09:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=TilM8cwD1XtU9mVpUnbiFz6uKljbIimEdcUk3gb5jRk=; b=PcSycXrsMN6eZvvZT3l83oLVQKHdvS4AkfEypcAyxMFPf0peXX4WOzI9hNHwQRCixo ih2LDjZA06TXyt1Ll87WWi0sAzHwdzQY94G5epUVcmECp162pwOVBxCRn8/vRcb4da+J UruMvHJa/rkE0+ZIF8WPdQl7AAINiSox3Dqz+Ojubtqopsh7uaq68IKen8Xcu120GilC 6+t3iXg94Rq6qCpLrLiOOtBiJsxKT48ouZeJ9r9EWfOBj63eLHpeM+S6M/3wRKUXdVqb jlMNKdctFiQ1udlcow/vaT/aEhh35dvXsspMDbZ64J5XDEuVg+PWI5X2baqvH+V6a9h8 CaaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=TilM8cwD1XtU9mVpUnbiFz6uKljbIimEdcUk3gb5jRk=; b=etGG65cdi2+wo//HdfJmRikkWnPxJi7Yv9rAB5fqOUukeNlDUD90sIWBm18xGpBIQ+ PvQJhCN8jWA7+bvHO4c+MUEbE8WspAzhBGXSMRll0l74p2rHY5MreohiYMfXFqLYx4Vk fm+p4MjtpdJvke57VSzs5c2qyyVvcAxxfOd763LpdxN8s2J4WbibM5PgfgTv/7QNRXaL PqptgM/YUbByVzKsGnPAhrxekltNQNituBbW5pkaKasUVqwfL/zifrNzOAsX9vYlYk3L qqWTu+ZVFUDGzeCdGu5Ogn7kcQoAes0VfWrgjlI4qSAhTXNiCMnJTr6vvQpsbC0KxVav zvPA== X-Gm-Message-State: APf1xPDyMvBWluu8rX2dsvHeOgIlG/FHyNb4HVAo1YI7BZOavqSUyDPU ajmYMXxQQYRVvkrdfA9LQz+j3n6dxxkpICEYkJ/QGw== X-Received: by 10.28.41.3 with SMTP id p3mr2747434wmp.140.1519233516426; Wed, 21 Feb 2018 09:18:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.55.204 with HTTP; Wed, 21 Feb 2018 09:18:35 -0800 (PST) In-Reply-To: References: <20180221030101.221206-1-shakeelb@google.com> From: Shakeel Butt Date: Wed, 21 Feb 2018 09:18:35 -0800 Message-ID: Subject: Re: [PATCH v2 0/3] Directed kmem charging To: Christopher Lameter Cc: Jan Kara , Amir Goldstein , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Greg Thelen , Johannes Weiner , Michal Hocko , Vladimir Davydov , Mel Gorman , Vlastimil Babka , linux-fsdevel , Linux MM , Cgroups , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 8:09 AM, Christopher Lameter wrote: > Another way to solve this is to switch the user context right? > > Isnt it possible to avoid these patches if do the allocation in another > task context instead? > Sorry, can you please explain what you mean by 'switch the user context'. Is there any example in kernel which does something similar? Another way is by adding a field 'remote_memcg_to_charge' in task_struct and set it before the allocation and in memcontrol.c, first check if current->remote_memcg_to_charge is set otherwise use the memcg of current. Also if we provide a wrapper to do that for the user, there will be a lot less plumbing. Please let me know if you prefer this approach. > Are there really any other use cases beyond fsnotify? > Another use case I have in mind and plan to upstream is to bind a filesystem mount with a memcg. So, all the file pages (or anon pages for shmem) and kmem (like inodes and dentry) will be charged to that memcg. > > The charging of the memory works on a per page level but the allocation > occur from the same page for multiple tasks that may be running on a > system. So how relevant is this for other small objects? > > Seems that if you do a large amount of allocations for the same purpose > your chance of accounting it to the right memcg increases. But this is a > game of chance. > > >