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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D603C433EF for ; Fri, 10 Jun 2022 10:56:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC4E6B00B5; Fri, 10 Jun 2022 06:56:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A34916B00B6; Fri, 10 Jun 2022 06:56:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AE6A8D0087; Fri, 10 Jun 2022 06:56:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 763EC6B00B5 for ; Fri, 10 Jun 2022 06:56:30 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 4C2DB6058A for ; Fri, 10 Jun 2022 10:56:30 +0000 (UTC) X-FDA: 79562022540.28.AD6C05B Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by imf25.hostedemail.com (Postfix) with ESMTP id D2B9EA0083 for ; Fri, 10 Jun 2022 10:56:29 +0000 (UTC) Received: by mail-yb1-f177.google.com with SMTP id y188so16903210ybe.11 for ; Fri, 10 Jun 2022 03:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UVWDkivKH1r0YSSFaw6OjTiC/YFmD6ezZssjPD8j23w=; b=RXvlY48vrnprsPhlzCN84oVM35sDdA8yC03DQqkStEKvLu2TPLb4+GXHZs42yE1HQx ttOCe8rdEkjLlqM3l9WDtsBCXfF4s+ChMyYv8Rr+fnyZ3LeVOcdMg6nEcEEKhCDER0yr fJTIw9qxUsAPtehkIPwv0SyUlxvDgwGcMmXAwiiBSv9/Zl7En+0nWztnAMnMDurZDcZY api97837F1HNyG80jX0Pe+SJ1JI7N7lMGqY67LErpq+TZ7CiRQ+ruwaymVLbslc02zZl XSlXazfrWTPWCpkIL90Vp8CX52j6WIsUEJ/9kUyf+tpm9WQnID+ZJjebzkTlpXQUnTgH lxFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UVWDkivKH1r0YSSFaw6OjTiC/YFmD6ezZssjPD8j23w=; b=h3qOk/sgNryf56L+PFwJ2N5OO6feWVgA/KJzT++t7971PheogCzXr/lvH5duXTxYSD KTWcdVQQ5VU+Uu39lCEZXRY1TUWJPZ/71lOVlaia1iGUNuXgkPlbbSJ1b6o353wd4L9C kkdwtSOUu3tn2FFbXcJ2by8wNgW6d3tqSwwfKOVGvlnZ/JoVFmAFcuM2QwUfwMIpn5X7 Zx/fZSDMGeyZKUH0q4dtDmUcrADWDO4JoFq8BlQxuZ7UCdS5X6QD4GeKHhyPTQJBh9YL hmjkbUZr4qeDh0GzQhX/reFvSiDBKiWzAT0YNR2nGV7keExjvr2tDtTbgEWfm1ZJGzei i4EA== X-Gm-Message-State: AOAM533PV8CRwEukYngn2r2XIlcjPMTKGaK4bJoFrIcuxTyYQHlLTsc1 JZXJ5cHlblcedi7+R3YUdVTq8bAr65StySlInjSXtA== X-Google-Smtp-Source: ABdhPJwm7RORsPVX9EpA+f/rpyV/bm7dA/SQ01EzbzV1yVf+JvmxjuyQHKmWdjTOtYg6usHy7cw6J444+7/JlR3E6Mo= X-Received: by 2002:a25:6546:0:b0:660:2a80:d6b6 with SMTP id z67-20020a256546000000b006602a80d6b6mr42004476ybb.617.1654858588911; Fri, 10 Jun 2022 03:56:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Naresh Kamboju Date: Fri, 10 Jun 2022 16:26:17 +0530 Message-ID: Subject: Re: [next] arm64: boot failed - next-20220606 To: Roman Gushchin Cc: Linux-Next Mailing List , open list , regressions@lists.linux.dev, lkft-triage@lists.linaro.org, Linux ARM , linux-mm , Stephen Rothwell , Andrew Morton , Ard Biesheuvel , Arnd Bergmann , Catalin Marinas , Raghuram Thammiraju , Mark Brown , Will Deacon , Shakeel Butt , Vasily Averin , Qian Cai Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654858589; a=rsa-sha256; cv=none; b=qvfGH03h46S33DKc9w6kqM3s3jt/TSmOkEZ0y6oK/CXDvp/cwORPKljrvvzUOQlq9rxohy lSXycxO+z9NPVlkRm2EANUvaK9g4Ojmgw7s3CWBAQxh8UFCw2UIBLqV55At4GmPa6bRQI/ 2Ub6W+gWavALM5Q4QZiUCkxCGe/vLug= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=RXvlY48v; spf=pass (imf25.hostedemail.com: domain of naresh.kamboju@linaro.org designates 209.85.219.177 as permitted sender) smtp.mailfrom=naresh.kamboju@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654858589; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UVWDkivKH1r0YSSFaw6OjTiC/YFmD6ezZssjPD8j23w=; b=x8W1YA12X49lU4U5XpmSF4bxuKVe9brGEYlU8FsAI42FccopPzFPamAUbgScX52ZDyzlm9 OcG2+YtUiEngabxJ0MP7hEl9aXvBzwAjQIjvFsmbrnc8OLj+TWm/oJK1v3OKTAnZ07cHsH yvIIQj7xUotTyGFKillVc7CLj2/DIwU= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D2B9EA0083 X-Stat-Signature: yojne689gnia346yyo6agt3rnpxg9w9u X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=RXvlY48v; spf=pass (imf25.hostedemail.com: domain of naresh.kamboju@linaro.org designates 209.85.219.177 as permitted sender) smtp.mailfrom=naresh.kamboju@linaro.org; dmarc=pass (policy=none) header.from=linaro.org X-HE-Tag: 1654858589-478797 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: Hi Roman, On Thu, 9 Jun 2022 at 22:57, Roman Gushchin wrote: > > On Tue, Jun 07, 2022 at 11:00:39AM +0530, Naresh Kamboju wrote: > > On Mon, 6 Jun 2022 at 17:16, Naresh Kamboju wrote: > > > > > > Linux next-20220606 arm64 boot failed. The kernel boot log is empty. > > > I am bisecting this problem. > > > > > > Reported-by: Linux Kernel Functional Testing > > > > > > The initial investigation show that, > > > > > > GOOD: next-20220603 > > > BAD: next-20220606 > > > > > > Boot log: > > > Starting kernel ... > > > > Linux next-20220606 and next-20220607 arm64 boot failed. > > The kernel panic log showing after earlycon. > > > > Reported-by: Linux Kernel Functional Testing > > Naresh, can you, please, check if the following patch resolves the issue? > (completely untested except for building) I have tested this patch on top of next-20220606 and boot successfully [1]. Tested-by: Linux Kernel Functional Testing > -- > > From 6a454876c9a1886e3cf8e9b66dae19b326f8901a Mon Sep 17 00:00:00 2001 > From: Roman Gushchin > Date: Thu, 9 Jun 2022 10:03:20 -0700 > Subject: [PATCH] mm: kmem: make mem_cgroup_from_obj() vmalloc()-safe > > Currently mem_cgroup_from_obj() is not working properly with objects > allocated using vmalloc(). It creates problems in some cases, when > it's called for static objects belonging to modules or generally > allocated using vmalloc(). > > This patch makes mem_cgroup_from_obj() safe to be called on objects > allocated using vmalloc(). > > It also introduces mem_cgroup_from_slab_obj(), which is a faster > version to use in places when we know the object is either a slab > object or a generic slab page (e.g. when adding an object to a lru > list). > > Suggested-by: Kefeng Wang > Signed-off-by: Roman Gushchin > --- > include/linux/memcontrol.h | 6 ++++ > mm/list_lru.c | 2 +- > mm/memcontrol.c | 71 +++++++++++++++++++++++++++----------- > 3 files changed, 57 insertions(+), 22 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 0d7584e2f335..4d31ce55b1c0 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -1761,6 +1761,7 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg) > } > > struct mem_cgroup *mem_cgroup_from_obj(void *p); > +struct mem_cgroup *mem_cgroup_from_slab_obj(void *p); > > static inline void count_objcg_event(struct obj_cgroup *objcg, > enum vm_event_item idx) > @@ -1858,6 +1859,11 @@ static inline struct mem_cgroup *mem_cgroup_from_obj(void *p) > return NULL; > } > > +static inline struct mem_cgroup *mem_cgroup_from_slab_obj(void *p) > +{ > + return NULL; > +} > + > static inline void count_objcg_event(struct obj_cgroup *objcg, > enum vm_event_item idx) > { > diff --git a/mm/list_lru.c b/mm/list_lru.c > index ba76428ceece..a05e5bef3b40 100644 > --- a/mm/list_lru.c > +++ b/mm/list_lru.c > @@ -71,7 +71,7 @@ list_lru_from_kmem(struct list_lru *lru, int nid, void *ptr, > if (!list_lru_memcg_aware(lru)) > goto out; > > - memcg = mem_cgroup_from_obj(ptr); > + memcg = mem_cgroup_from_slab_obj(ptr); > if (!memcg) > goto out; > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 4093062c5c9b..8c408d681377 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -783,7 +783,7 @@ void __mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val) > struct lruvec *lruvec; > > rcu_read_lock(); > - memcg = mem_cgroup_from_obj(p); > + memcg = mem_cgroup_from_slab_obj(p); > > /* > * Untracked pages have no memcg, no lruvec. Update only the > @@ -2833,27 +2833,9 @@ int memcg_alloc_slab_cgroups(struct slab *slab, struct kmem_cache *s, > return 0; > } > > -/* > - * Returns a pointer to the memory cgroup to which the kernel object is charged. > - * > - * A passed kernel object can be a slab object or a generic kernel page, so > - * different mechanisms for getting the memory cgroup pointer should be used. > - * In certain cases (e.g. kernel stacks or large kmallocs with SLUB) the caller > - * can not know for sure how the kernel object is implemented. > - * mem_cgroup_from_obj() can be safely used in such cases. > - * > - * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(), > - * cgroup_mutex, etc. > - */ > -struct mem_cgroup *mem_cgroup_from_obj(void *p) > +static __always_inline > +struct mem_cgroup *mem_cgroup_from_obj_folio(struct folio *folio, void *p) > { > - struct folio *folio; > - > - if (mem_cgroup_disabled()) > - return NULL; > - > - folio = virt_to_folio(p); > - > /* > * Slab objects are accounted individually, not per-page. > * Memcg membership data for each individual object is saved in > @@ -2886,6 +2868,53 @@ struct mem_cgroup *mem_cgroup_from_obj(void *p) > return page_memcg_check(folio_page(folio, 0)); > } > > +/* > + * Returns a pointer to the memory cgroup to which the kernel object is charged. > + * > + * A passed kernel object can be a slab object, vmalloc object or a generic > + * kernel page, so different mechanisms for getting the memory cgroup pointer > + * should be used. > + * > + * In certain cases (e.g. kernel stacks or large kmallocs with SLUB) the caller > + * can not know for sure how the kernel object is implemented. > + * mem_cgroup_from_obj() can be safely used in such cases. > + * > + * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(), > + * cgroup_mutex, etc. > + */ > +struct mem_cgroup *mem_cgroup_from_obj(void *p) > +{ > + struct folio *folio; > + > + if (mem_cgroup_disabled()) > + return NULL; > + > + if (unlikely(is_vmalloc_addr(p))) > + folio = page_folio(vmalloc_to_page(p)); > + else > + folio = virt_to_folio(p); > + > + return mem_cgroup_from_obj_folio(folio, p); > +} > + > +/* > + * Returns a pointer to the memory cgroup to which the kernel object is charged. > + * Similar to mem_cgroup_from_obj(), but faster and not suitable for objects, > + * allocated using vmalloc(). > + * > + * A passed kernel object must be a slab object or a generic kernel page. > + * > + * The caller must ensure the memcg lifetime, e.g. by taking rcu_read_lock(), > + * cgroup_mutex, etc. > + */ > +struct mem_cgroup *mem_cgroup_from_slab_obj(void *p) > +{ > + if (mem_cgroup_disabled()) > + return NULL; > + > + return mem_cgroup_from_obj_folio(virt_to_folio(p), p); > +} > + > static struct obj_cgroup *__get_obj_cgroup_from_memcg(struct mem_cgroup *memcg) > { > struct obj_cgroup *objcg = NULL; > -- > 2.35.3 [1] https://lkft.validation.linaro.org/scheduler/job/5156201 -- Linaro LKFT https://lkft.linaro.org