From patchwork Sun Sep 18 20:47:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12979586 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 8C5A6ECAAD8 for ; Sun, 18 Sep 2022 20:48:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C94494000A; Sun, 18 Sep 2022 16:48:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0756F940008; Sun, 18 Sep 2022 16:48:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBD0394000A; Sun, 18 Sep 2022 16:48:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CB256940008 for ; Sun, 18 Sep 2022 16:48:04 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9B088A03C1 for ; Sun, 18 Sep 2022 20:48:04 +0000 (UTC) X-FDA: 79926393288.02.276DDCE Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf24.hostedemail.com (Postfix) with ESMTP id 41B7E180006 for ; Sun, 18 Sep 2022 20:48:04 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id n6-20020a5b0486000000b006aff8dc9865so12710178ybp.11 for ; Sun, 18 Sep 2022 13:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date; bh=Lw4scwFqzp1HreT7ffbgAOkeM6+LsydrTcmSI+YwUBg=; b=i+DsSbyQyJa9qdQMAHmq56D1M1P8DGQCwaK6s+/VBX6H8yAssf2yez96SlWRqiTTGe wQd/ywEIQEMsT5az0U0OZSmwRmIW8KQT1xMa4nTw8ddhOICbEoYsVNbTJGevtayyzbDx SW5ONhnfrXUJP1/QaIs2tJclO/T20QgE/BY4wp1OD3Hy00DixaxiVNHfDBPCRO6fXjtS ne1ZZ7y7oqP6tQ0I4h25wiQYeUDCYfvzACQ3Yycps18qPqYIpY/g8vy7/P9hga2JwTPx c2OOAN/+5CnQ7N7kyL8T5ncebdN+DA9ywGgUYdnj+Fy1wuY03MK+Q5nU7J5FJSuXYomw xP5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=Lw4scwFqzp1HreT7ffbgAOkeM6+LsydrTcmSI+YwUBg=; b=dZp7bLVHc9cB/PwjV7hhFYSu6KehmQo/G9xNL1Rm0ytzkN7ElWl1eZ4hvT+3tKBrCH HAFNCC5g9C9fxKqnmTD/1rc6g5vDF2uV9pLiTw8I6KLhs0IzfgPZQfB85c1zsV3SgRyo d4MLvsRKaw6ppMZJJxpWn/RBQnmnBRmiby7UbZypRboWqDVEFWj6Tu6+6M7IbVz7IxIB YhKROJfRGw44tXagp64yOLA+8lNEEikhGtPjjJ8Y0xHcchc/hWdeW30igEzj8j7/OBp6 DnTegKF8SkGoUzOBJEiuGPHRfLnI4hCYApJzMP0R9noX3JINKrx+llhVRSA5vo6Ce+L8 Mlag== X-Gm-Message-State: ACrzQf2Xxy3SULaCmei5yOgN2xLC1heVFQvniwDFWxhYV/GWaUOvEch/ iQr/6Ohi07h8QBlI0iQzvKqUSprZKz0= X-Google-Smtp-Source: AMsMyM41HFDvPrAKBbudcLn8GRnN0tvMl7hkoDh0FrTlA0nyM+Se6UA6dczZsxeYcseJbgADNU4yhD1FHRI= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:ccff:7b62:4ed6:2946]) (user=yuzhao job=sendgmr) by 2002:a5b:cc4:0:b0:6ae:2a6c:59e6 with SMTP id e4-20020a5b0cc4000000b006ae2a6c59e6mr11920830ybr.59.1663534083673; Sun, 18 Sep 2022 13:48:03 -0700 (PDT) Date: Sun, 18 Sep 2022 14:47:48 -0600 In-Reply-To: <20220918204755.3135720-1-yuzhao@google.com> Message-Id: <20220918204755.3135720-4-yuzhao@google.com> Mime-Version: 1.0 References: <20220918204755.3135720-1-yuzhao@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Subject: [PATCH v14-fix 04/11] mm: multi-gen LRU: fix warning from __rcu From: Yu Zhao To: Andrew Morton Cc: linux-mm@kvack.org, Yu Zhao , kernel test robot ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663534084; a=rsa-sha256; cv=none; b=Eb5Yaujs9aj97rgJg/YnXGARuUSKursuW92drs8Wm//4HNHNh3PJfnDc3zCPJ54FgZO2NU uEuufQg3SIaqXAyjiEqTOBnh5QUZbk7/HcI+3YJu4Dp38e/lwsXZXL210gOPQ8qs7Bl+Tt KedrGB1Zq/rvM2TuZYfrE87i+B2i/zA= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=i+DsSbyQ; spf=pass (imf24.hostedemail.com: domain of 3A4QnYwYKCMgC8Dvo2u22uzs.q20zw18B-00y9oqy.25u@flex--yuzhao.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3A4QnYwYKCMgC8Dvo2u22uzs.q20zw18B-00y9oqy.25u@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663534084; 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=Lw4scwFqzp1HreT7ffbgAOkeM6+LsydrTcmSI+YwUBg=; b=zcmHx9w+mghnmdsrp7JWhv/1rbulCx3PrnPPnywdui5DCcZjpDI37Jo/gEyAS3V9AUQEiV xiOQzuhPhh7PEjzOXO7JHrzyiPaoGoCajcHoi728MLOZiL6maLiosnBVOEjLI89rlAsJRa PvXYB2xo0CrcXgSTx/nhVBb/FZjFJjg= Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=i+DsSbyQ; spf=pass (imf24.hostedemail.com: domain of 3A4QnYwYKCMgC8Dvo2u22uzs.q20zw18B-00y9oqy.25u@flex--yuzhao.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3A4QnYwYKCMgC8Dvo2u22uzs.q20zw18B-00y9oqy.25u@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: s46xqdig33rzsms9ojzo1bwo1knotzzg X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 41B7E180006 X-HE-Tag: 1663534084-964627 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: Link: https://lore.kernel.org/r/CAOUHufY8+O_MwkrPzgfBKSFwLJ1v6LPDox1yGV0tjX4ozjh2Dw@mail.gmail.com/ Reported-by: kernel test robot Signed-off-by: Yu Zhao --- mm/memcontrol.c | 2 +- mm/vmscan.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8086edbdd39b..ac6440daf208 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6289,7 +6289,7 @@ static void mem_cgroup_attach(struct cgroup_taskset *tset) return; task_lock(task); - if (task->mm && task->mm->owner == task) + if (task->mm && READ_ONCE(task->mm->owner) == task) lru_gen_migrate_mm(task->mm); task_unlock(task); } diff --git a/mm/vmscan.c b/mm/vmscan.c index 629518813b59..8291808ec535 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3270,15 +3270,17 @@ void lru_gen_del_mm(struct mm_struct *mm) void lru_gen_migrate_mm(struct mm_struct *mm) { struct mem_cgroup *memcg; + struct task_struct *task = rcu_dereference_protected(mm->owner, true); - lockdep_assert_held(&mm->owner->alloc_lock); + VM_WARN_ON_ONCE(task->mm != mm); + lockdep_assert_held(&task->alloc_lock); /* for mm_update_next_owner() */ if (mem_cgroup_disabled()) return; rcu_read_lock(); - memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); + memcg = mem_cgroup_from_task(task); rcu_read_unlock(); if (memcg == mm->lru_gen.memcg) return;