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.3 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_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 9F223C433DF for ; Sat, 20 Jun 2020 00:16:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 397BB2256E for ; Sat, 20 Jun 2020 00:16:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kiDbVtnD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 397BB2256E 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 5F4FB6B0078; Fri, 19 Jun 2020 20:16:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A67A6B007B; Fri, 19 Jun 2020 20:16:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E2626B007D; Fri, 19 Jun 2020 20:16:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 364CB6B0078 for ; Fri, 19 Jun 2020 20:16:16 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A24C02DFA for ; Sat, 20 Jun 2020 00:16:15 +0000 (UTC) X-FDA: 76947673110.09.loaf21_020701226e1d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 7C5A7180AD806 for ; Sat, 20 Jun 2020 00:16:15 +0000 (UTC) X-HE-Tag: loaf21_020701226e1d X-Filterd-Recvd-Size: 4537 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Sat, 20 Jun 2020 00:16:15 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id y13so6539645lfe.9 for ; Fri, 19 Jun 2020 17:16:15 -0700 (PDT) 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=yH96O9ee+Uh/yst0CCmNawAFM7J3cnfjN7OBaXkMBuo=; b=kiDbVtnDRJrd0GU7d+nWT7DQSV0scWLq3IyR0O/sZHnovyNUR/N8Bpwh6t3PlP0oWE Leao5UmXekcawPaolmYTpEHrGtcFt+V59dfF+BpyaYEC5smEW+cpE/ofJ5Mz4M+JVy8h XFCzI5u5VGSoaobU+A0Cfrz5i8RSUIlKq/r90lYVIFW0EOkTVgweezwves/J7cakSLFL 8RJMOlrhDtCTKOP0bsuoLdh4yI53KWbNy2T/77Cp8VqlGPCq4Tt3oyvLd95hz3tLXTVV bLxqKp1uD4nF41KEeRvHqGEjaQM5x4+cd+WA6usKphDfHFyoddYNg0EqCh3PKHP0/V59 s16Q== 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=yH96O9ee+Uh/yst0CCmNawAFM7J3cnfjN7OBaXkMBuo=; b=AjZqcAWgUGRT2vfUg8LIfvGTD50AfnoxGtM7L6RU65C9KBkhD8QEhOHbIlrPp6WsnR B//2/tED/pLsd1ldgFfNP/UjlIxN5ZoatpK395HCuhfZZAnO3oboaLQHRNclBedAd8+I lXZ7g19rmzBtKYRek+aX5njkfs1M9Q5aE+0mSZ/mTR9jKY7EFEVrok9eh8IzaKYdn2z+ fP7XLVrNAc5d6scQ48c+7Ud02+WUeWxX5bKJYNI/mLKgW4ZsfXXQTL6bRKVR93oh0zyr uo+MUv55ER2b4SZzAIt0eGXy8+VuAkkKZgkisQpHTkxNqzMvRTZ9NUO9jtov9efaMoLm a4Hg== X-Gm-Message-State: AOAM530j1PMnrI8Q0BxVWP2k9/EkVWy1C3fEU9M3t6FNQRUDDJyMcJcp 5B+C0W918bIeemkq9M7CT2kh8TUqNIgwfdalWzywIw== X-Google-Smtp-Source: ABdhPJy8ryuL3BCw9hMm/5NTZWmr36I40dkkLmQ/Ajt7q/cXxbYe2hymUNmDHkhdO7xsvm0E319wYDL7TZ6lkrF+vfI= X-Received: by 2002:a19:4301:: with SMTP id q1mr3259839lfa.96.1592612173404; Fri, 19 Jun 2020 17:16:13 -0700 (PDT) MIME-Version: 1.0 References: <20200608230654.828134-1-guro@fb.com> <20200608230654.828134-9-guro@fb.com> In-Reply-To: <20200608230654.828134-9-guro@fb.com> From: Shakeel Butt Date: Fri, 19 Jun 2020 17:16:02 -0700 Message-ID: Subject: Re: [PATCH v6 08/19] mm: memcg/slab: save obj_cgroup for non-root slab objects To: Roman Gushchin Cc: Andrew Morton , Christoph Lameter , Johannes Weiner , Michal Hocko , Linux MM , Vlastimil Babka , Kernel Team , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 7C5A7180AD806 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 Mon, Jun 8, 2020 at 4:07 PM Roman Gushchin wrote: > > Store the obj_cgroup pointer in the corresponding place of > page->obj_cgroups for each allocated non-root slab object. > Make sure that each allocated object holds a reference to obj_cgroup. > > Objcg pointer is obtained from the memcg->objcg dereferencing > in memcg_kmem_get_cache() and passed from pre_alloc_hook to > post_alloc_hook. Then in case of successful allocation(s) it's > getting stored in the page->obj_cgroups vector. > > The objcg obtaining part look a bit bulky now, but it will be simplified > by next commits in the series. > > Signed-off-by: Roman Gushchin > Reviewed-by: Vlastimil Babka One nit below otherwise: Reviewed-by: Shakeel Butt > --- [snip] > +static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, > + struct obj_cgroup *objcg, > + size_t size, void **p) > +{ > + struct page *page; > + unsigned long off; > + size_t i; > + > + for (i = 0; i < size; i++) { > + if (likely(p[i])) { > + page = virt_to_head_page(p[i]); > + off = obj_to_index(s, page, p[i]); > + obj_cgroup_get(objcg); > + page_obj_cgroups(page)[off] = objcg; > + } > + } > + obj_cgroup_put(objcg); Nit: we get the objcg reference in memcg_kmem_get_cache(), doesn't it look cleaner to put that reference in memcg_kmem_put_cache() instead of here. > + memcg_kmem_put_cache(s); > +} > +