Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp269353ybv; Wed, 19 Feb 2020 21:12:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwf8K3F5YluPdTMsVo7+OlPPOJXxriTYYpveV3+I5JG+SbojIpCm76m4WoGPRECpaZOHS7V X-Received: by 2002:a05:6830:22ca:: with SMTP id q10mr23806251otc.280.1582175574634; Wed, 19 Feb 2020 21:12:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582175574; cv=none; d=google.com; s=arc-20160816; b=kuVfu8dw1IFoGCPquOUEjF6MvOxdSRvT2tfCL8p+2nbyW4RnjZDJs9UAgDZ9W/cxi/ HGEck9GLDLL0k42BXaMrkrN0hBWDmZmgUN14qOoZmvA7yJY9s3nUpiBmts/yj8Ljh+1O oNzfjHI5CKI9CRFy9keZeBHZVUTc0YkWydzSrHTjGl37ODhu5ujWZoKzdfXz3yjx84Nf MTFVZYsYdRaT2Jq4Jfl8gLp5YnMxiURAL++jBlE20pWL83j+Tpp72iSjN8vm731XKwOK CE39NQZLmc0DGgDnrNWLk5Vtij9qH1apeUHdpmvgSfTnZ1C0CP2lgf8Gk+ITPf33Q4V1 TRnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=2X37snKsWsbjnSC5G8JKDN8U4XxTo8mCwhpNzWhIZ/g=; b=AVgAfnwH6IlWsw1HYq7c2gWnwohdtBNrl1m20xdoJLJ96FtkW8YZeKWzeF0Q+G9hfl fOM3Jx3tVROCufSvDWZNFZbBz20smZ90KFIHylLnlxwmXA8k064X7NAuHYC9j7TMAqO3 9k6KT8M2IjiKZVboCmRCT9bwm3cNuZl3KPQuBQm8520dp6RfpQOh0UZRZOQfJWBjU7Iu x15NmaeN4n+IdZ/CEwpLY22MPD79XDwfYKTF2nOVAB6ZDgyGoA6DIqvndb36raHSJrAZ wJ+C4DlbpSCKWcwvEsRAIcZFbZzoRUGTVke8bGoYfjJwljRd+q7BDYiSDSNyhXEH9Xhp QJUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Acq69Agx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si1079635otp.84.2020.02.19.21.12.42; Wed, 19 Feb 2020 21:12:54 -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=@gmail.com header.s=20161025 header.b=Acq69Agx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgBTFMY (ORCPT + 99 others); Thu, 20 Feb 2020 00:12:24 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40746 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727576AbgBTFMW (ORCPT ); Thu, 20 Feb 2020 00:12:22 -0500 Received: by mail-pf1-f194.google.com with SMTP id b185so1299202pfb.7 for ; Wed, 19 Feb 2020 21:12:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2X37snKsWsbjnSC5G8JKDN8U4XxTo8mCwhpNzWhIZ/g=; b=Acq69AgxNmIWtDhcNNl9N3V0JLpmicXt0Bv9AbkvFUJAHq3y91fvxJdDryQwz+cnpi Pfm0pSzDI/CaisNYqIVBO/V1ClVjL+SXL2KT3EUETedpQ2XWinfVYgT2AedKKPkhoQDP zxQYofRDAjLEWzKHaPf6ToP1AT4OtI5kDOlfdbtkcMlqY9KfEekAaNk2ULAWA5Kr9uRs mmI87WTsKFiasYV6UZhrWx6G3gd29kPFGn9SQ0UruMk33Np3tYR2tTmJ644tm7wB466E m1vb18qsNVNnanSgzygrz3lHf1Ngfg0Ef2TOYBJOp5clE9xXnggl972BSJLHQkS87Dg8 QMlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2X37snKsWsbjnSC5G8JKDN8U4XxTo8mCwhpNzWhIZ/g=; b=ogbW3ZE8PELgGuWe+0DHOKDyZnuuBNoScdCJrrGYSyl2+5Ye/enq574ZowHW0GciZ0 AOXABkFKnBQoXxEUhONpGYeaRIm61A+VmQibLwNxKyP82LcHbP6N56F/58ecg2Edn5iA k7lJ+QQb08yGphH/Ni937uFntieHdDHlGnoiWf6bPe/cbr4VPHLMuKGk96a7Xs9C7+Bu t+OA9VvLYEtRjwzb5kZx7AUfwmo2lPijWiisc4RGoXyF3IhqcXcI9zNXH2pqXrzizqgZ Nf9prUDjFj3MF95J95Dy3pF5XlSqC5Ue4ZpjhlaZkURwuOHXLJqpqct+uqPoMfrHdRq2 2AMg== X-Gm-Message-State: APjAAAW3fW2thw0AY+ubjnEWjqLPEfbIVk5liDWZgs8Kv4pDvWCQFSHo F/Z7sBSIb3K8KF/xGE1bbQQ= X-Received: by 2002:a62:18c9:: with SMTP id 192mr29983465pfy.117.1582175542013; Wed, 19 Feb 2020 21:12:22 -0800 (PST) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id t15sm1472599pgr.60.2020.02.19.21.12.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Feb 2020 21:12:21 -0800 (PST) From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Hugh Dickins , Minchan Kim , Vlastimil Babka , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Subject: [PATCH v2 6/9] mm/workingset: handle the page without memcg Date: Thu, 20 Feb 2020 14:11:50 +0900 Message-Id: <1582175513-22601-7-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582175513-22601-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1582175513-22601-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joonsoo Kim When implementing workingset detection for anonymous page, I found some swapcache pages with NULL memcg. From the code reading, I found two reasons. One is the case that swap-in readahead happens. The other is the corner case related to the shmem cache. These two problems should be fixed, but, it's not straight-forward to fix. For example, when swap-off, all swapped-out pages are read into swapcache. In this case, who's the owner of the swapcache page? Since this problem doesn't look trivial, I decide to leave the issue and handles this corner case on the place where the error occurs. Signed-off-by: Joonsoo Kim --- mm/workingset.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/workingset.c b/mm/workingset.c index a9f474a..8d2e83a 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -257,6 +257,10 @@ void *workingset_eviction(struct page *page, struct mem_cgroup *target_memcg) VM_BUG_ON_PAGE(page_count(page), page); VM_BUG_ON_PAGE(!PageLocked(page), page); + /* page_memcg() can be NULL if swap-in readahead happens */ + if (!page_memcg(page)) + return NULL; + advance_inactive_age(page_memcg(page), pgdat, is_file); lruvec = mem_cgroup_lruvec(target_memcg, pgdat); -- 2.7.4