Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3396733ybh; Mon, 16 Mar 2020 22:43:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvWcJOi+wuZUE4JGA5DfevybYGuGhYHl6B+mSuYNfO+coPwGF1N3837PrntezVrNFp7IzFW X-Received: by 2002:a05:6830:3090:: with SMTP id f16mr2238557ots.211.1584423800218; Mon, 16 Mar 2020 22:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584423800; cv=none; d=google.com; s=arc-20160816; b=bMTazKxlSqAYIHnRNpxkWsF4WXanw8mfNhYeTayTJ1UQQDPsHy0rtpCrWQNn5/iC+Z QBz67SOUpkXBAbNr02WkmInZYYkw8+Z19yCBcIuJuElv4Q/I02ytfZVMLyjra4BhGwwz RDJ5OnUuWQ1m2n3lhdfwqdzTYGma/yVePjjpuzDScLn1oZTxj7bvYl0E+Ag8XcNahEVn BJwjIaTCo/Iz7WhodixLT/3Nry/bbaXeJMgrnf8RDHjnhAbFTnmvI2TRjSUrWPNnhg3K 0n6ypYmgrXXYCMBQFOjcYYx242eCg9KLPpq4WihuxSPIkS4G6Pn2Uzm+0+Y5W2BdAE+D soZg== 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=K3oGV2b5wOjBLTeM0f7AFAw+ieoqPyXgWa0/besm8gsv+juQM2L0gT59nDIIffxEON Itq2HCdmpbs8rjv60IikC0Gq3B0SJ9RP+phGoFAwu0fNncAhj/py/zLsH2TP3fKqXBj7 PLxEOZEL4xCgi633yhNF/F52wT+BnHf7K3d/hf6HdwuhHn5bs3bdfDEDjWJMw50g3gRm fwA5b06XGKgzZyZ7Z0n+SRh9R6z3LORfqP8OvKWMty/arOH69iLIYVpPnVp38rZYV1fI LJQ2HOAVZOombyM9AY8UnT6hg0c4gMHJLH+1U9laiPa0xoIyDCqw3zILU62aGY914a+k pzyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Va/f0gGE"; 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 n9si1127851ota.103.2020.03.16.22.43.08; Mon, 16 Mar 2020 22:43:20 -0700 (PDT) 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="Va/f0gGE"; 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 S1726574AbgCQFm1 (ORCPT + 99 others); Tue, 17 Mar 2020 01:42:27 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36763 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgCQFm0 (ORCPT ); Tue, 17 Mar 2020 01:42:26 -0400 Received: by mail-pg1-f193.google.com with SMTP id z72so1250792pgz.3 for ; Mon, 16 Mar 2020 22:42:26 -0700 (PDT) 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=Va/f0gGE31wRD/TpGDskcGX2Bef2+hsg3s3UovewxNs+hxNqvyVU5KGLQw3dr5ThQO 7fzmRVnDqkMUog4CZ9FAIBeHkKqg2Q1Frh+sYHmLspg5JB2MGLV4UgwE0eQ80S5f2dKW ZV/dJ/LIHbWXpoivteZR8rbN/cUhoheqoNq8bn4CbNg72ZZjcAHlL2Src5W6j62AUWiN dHfDYzcSQz2j8Nxz8F2PckPsowOUf+G/M6VPH531/csFrfA77H7cS8nOEJjM0gesiVW0 XrWsRkV3MwgYK0VADbCHO9UBqPFCnM0df/HrTvxQrXLqHZKvlk2eAbQ5sRI+3xCv5P0L lo3Q== 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=DATHk4hthfwocup7vKN5foHZld8kNCa7Ux5hqADcy31XmzQs+MxjoPjsuPPEMGbjDG DqH1HtMYs5ZjYTlEX6uq/cFOD3jTLYrssYNznq7Le0NjM45y3mltfTEyCMjw0JPJ/wkc TPTDIesgJmhAYKNAoDiPsSX8O8bE2sa/bPjjxmWONp2UKuO73GPj3/fz6AKjvZEGDx5N 1T8UQ29Hs20MY9OnmvNSKTmMziRCi7NZghAUMmNMh+DCqu62Bm6uyGm+Wicvyywd5ykz Ixo3ZAcH5/X0kNPn3Lf92fQWAN9oKafgqTPtclGhcOcajipmig1aRrW5wozIYdtDREAY xmCA== X-Gm-Message-State: ANhLgQ03UDGJ2OUIcqBqBX5auD2UMi6A88nD/sfCyi0BxWxzz8sPA9wx lSkCBXdsbS2ci9bMkYwADKs= X-Received: by 2002:a62:a116:: with SMTP id b22mr3541272pff.122.1584423745852; Mon, 16 Mar 2020 22:42:25 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id i21sm1141757pgn.5.2020.03.16.22.42.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Mar 2020 22:42:25 -0700 (PDT) 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 v3 6/9] mm/workingset: handle the page without memcg Date: Tue, 17 Mar 2020 14:41:54 +0900 Message-Id: <1584423717-3440-7-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584423717-3440-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1584423717-3440-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