Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4601669ybv; Mon, 10 Feb 2020 23:27:07 -0800 (PST) X-Google-Smtp-Source: APXvYqxbcTyl9BREye0M6rg6+6ID3n2te2vQDhS+7BHzRe2E91biLu+/QKHr5cPaE5K01rhcNOgZ X-Received: by 2002:aca:4f8e:: with SMTP id d136mr1974980oib.61.1581406027304; Mon, 10 Feb 2020 23:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581406027; cv=none; d=google.com; s=arc-20160816; b=NScPgijVwvK0S2IjsMX8R2o0AIzcMlsa7cO2zp9geYqTxPhnq3igu+GeTvru3JuOd4 S9ULVGCKelEA1dYoMX/zDWbe6AZTo565u351mhJUrsyISzUCaP6eNPk0Z1IMR42H5qYc Y6mPps6bF9fnnGJFdODTrFijGZpemvBereNGBTEUDEy4KgB3R5gPnygaHLXADqntScpM 6IpJx3cqUbvkdqsnVdw5dXRXsRLvaNlEQvYLX4GzL6DNzoDWpm0P9hhEzKnLPVJUANWV /aYHBa1u2ovotWD6HDvdhqI9IljtB9AxgDHwHuFrBDVEIFW5tbAm8XFcgLEtZXiP7j50 qyZg== 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=vhjcjAXSe/y4wvj+GJktp0lCL/rhZzJbEkZv0Rz8J3s=; b=pMtEietw8bXtjTKZeoPaXJqwPC/QJuFnBw+NdbDef5M7Qcnlym6QqAcH3R14wrQvUx /i+ONOVhkD+MX3/dxYE97FITR0vsZpEaeO+uYPCwyQo8rHFERV3VeTH4Pv25pgvbOlB1 upQ3u2Bo700WqBaL7fINiL4He9g+BIJkG7t3W7tLFMieQif3b2CNKrhaRKwvF3MihEYX gpKVOZBd+Vc5VVWdVRB0fVU+IRtPQsRlW5w/9FISemAsXScHxLmlzFFQv/UJGa+6zlG4 N5t8mVOsSry+oAYvP6Qh2Iq43HozlKlgpbsNNKb6dzgYMbicRRi4OERBPy0/o6QRudbT YmBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=h8+gkVEx; 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 t185si1406325oib.39.2020.02.10.23.26.55; Mon, 10 Feb 2020 23:27:07 -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=h8+gkVEx; 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 S1728318AbgBKGUb (ORCPT + 99 others); Tue, 11 Feb 2020 01:20:31 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40071 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728307AbgBKGU3 (ORCPT ); Tue, 11 Feb 2020 01:20:29 -0500 Received: by mail-pl1-f193.google.com with SMTP id y1so3833405plp.7 for ; Mon, 10 Feb 2020 22:20:29 -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=vhjcjAXSe/y4wvj+GJktp0lCL/rhZzJbEkZv0Rz8J3s=; b=h8+gkVEx9vXkAAQFIngjWuVqspD+lGBkSftfueODYCJIA221nWA1wOUmU3avSebYhZ P2VcGSpdUnlXcgiZlM863mQ/v8v/w/5R38HzPKONS+l0YXIwOK46aJaEF38GVXQRufBx J25LMmyM9hUSO5x6cw2ri3kk0DTDR+FPfXwkhuOWlDTARBuwDokhkjfxEKFRP4tbU+l+ ZmcZaAuIdbYKwJ9P7VemfBjeQTkzE4WAfvh7uV7fW9Y1LDbbJ/OSHq/eSBNCl8N/SNGq QcKHCxyaRTtcnwx064m4RV+LYWzqZ2JPRtXpgQco0TuzPg/dUNGFUccyjm4WhIw5ZWBG q9AA== 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=vhjcjAXSe/y4wvj+GJktp0lCL/rhZzJbEkZv0Rz8J3s=; b=Oe6zAzM7IkMBToyDOLq46Fvqe0ZtgipttB+zoUOuqhidbNgUIVHMDgvUo87S6Nd+bI afFt2BrjPnIPx0qFd5yPXUsiSkEz86Bh+jNYeNnCpblgCSe++QHQlJHxC2tk4ekA347L eWkiuM/Y2xZJ/gGrjq9NMBsyqS/VwDbhvE1xHA25W93J1STs3nUyHdICIGTp5YqhbeO/ d+Ke4FYYYI/S7NC7ucS2/zVWNfgxZj9UITjuXRTbZoMhpQw4X44h2pSnWIp+/spOplVJ fb0OcQBIg+/r3HaQw3mkxK0ALT7pcQqCOmx2RGFxygnGWp/wXUlRM3Ndk5b5eBGeGx1m 6AqA== X-Gm-Message-State: APjAAAWUR8kBU1H8Ak+ALtnOT1S74lBsMKbAtYUlK8J51KDBTSoPeG3a va6VBAkO7FTNJqknrK1kOh8= X-Received: by 2002:a17:90a:8586:: with SMTP id m6mr1854877pjn.121.1581402028634; Mon, 10 Feb 2020 22:20:28 -0800 (PST) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id x197sm2578696pfc.1.2020.02.10.22.20.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Feb 2020 22:20:28 -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 6/9] mm/workingset: handle the page without memcg Date: Tue, 11 Feb 2020 15:19:50 +0900 Message-Id: <1581401993-20041-7-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1581401993-20041-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1581401993-20041-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 636aafc..20286d6 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