From patchwork Fri Oct 25 23:27:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 11213209 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83629112C for ; Fri, 25 Oct 2019 23:28:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4CA2921E6F for ; Fri, 25 Oct 2019 23:28:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="WqnNccPH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CA2921E6F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6E7056B0003; Fri, 25 Oct 2019 19:28:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 697DF6B0006; Fri, 25 Oct 2019 19:28:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5ACE66B0007; Fri, 25 Oct 2019 19:28:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 33C736B0003 for ; Fri, 25 Oct 2019 19:28:37 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id CAECF2463 for ; Fri, 25 Oct 2019 23:28:36 +0000 (UTC) X-FDA: 76083898632.22.kick43_10efb21dc6c42 X-Spam-Summary: 2,0,0,7a2f02ca931651ac,d41d8cd98f00b204,prvs=520100299e=guro@fb.com,::mhocko@kernel.org:hannes@cmpxchg.org:linux-kernel@vger.kernel.org:kernel-team@fb.com:guro@fb.com:vdavydov.dev@gmail.com:shakeelb@google.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1277:1313:1314:1345:1437:1516:1518:1534:1541:1711:1730:1747:1777:1792:1981:2194:2199:2393:2559:2562:2900:3138:3139:3140:3141:3142:3352:3865:3867:3868:3872:4321:4605:4860:5007:6261:6653:7514:7903:8957:10004:10400:11026:11658:11914:12043:12291:12294:12296:12297:12438:12555:12679:12683:12895:12986:13069:13255:13311:13357:14096:14097:14181:14394:14721:21080:21451:21627:21795:30051:30054:30064,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: kick43_10efb21dc6c42 X-Filterd-Recvd-Size: 4266 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Oct 2019 23:28:36 +0000 (UTC) Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9PNSSBE023087 for ; Fri, 25 Oct 2019 16:28:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=ZG/Rp0U9V1GZOvfP/+5tTW4GxOxccc3k62QOVqXPKFw=; b=WqnNccPHtxf/h2T43Jhgq/aMjlDc8eyeqXajd6mZqGvxeNk/wHtUIYP99KYCMc9dE7ye qlUZT7/cKlbgZnJlEj1UlCkniS7ZJXbVzHILjKw5FoQtwaBiC7+VI8DDz6rp1k36Y9vC AEHNNYpHSrtnNkfaalyYCKGwk8BhzxCpPng= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2vue7qfrhg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 25 Oct 2019 16:28:35 -0700 Received: from 2401:db00:30:6007:face:0:1:0 (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 25 Oct 2019 16:28:34 -0700 Received: by devvm2643.prn2.facebook.com (Postfix, from userid 111017) id 89D70192BA24C; Fri, 25 Oct 2019 16:28:31 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm2643.prn2.facebook.com To: CC: Michal Hocko , Johannes Weiner , , , Roman Gushchin , Vladimir Davydov , Shakeel Butt Smtp-Origin-Cluster: prn2c23 Subject: [PATCH] mm: slab: make page_cgroup_ino() to recognize non-compound slab pages properly Date: Fri, 25 Oct 2019 16:27:10 -0700 Message-ID: <20191025232710.4081957-1-guro@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-25_11:2019-10-25,2019-10-25 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 spamscore=0 suspectscore=1 adultscore=0 mlxlogscore=998 lowpriorityscore=0 mlxscore=0 bulkscore=0 malwarescore=0 phishscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910250215 X-FB-Internal: deliver 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: page_cgroup_ino() doesn't return a valid memcg pointer for non-compund slab pages, because it depends on PgHead AND PgSlab flags to be set to determine the memory cgroup from the kmem_cache. It's correct for compound pages, but not for generic small pages. Those don't have PgHead set, so it ends up returning zero. Fix this by replacing the condition to PageSlab() && !PageTail(). Before this patch: [root@localhost ~]# ./page-types -c /sys/fs/cgroup/user.slice/user-0.slice/user@0.service/ | grep slab 0x0000000000000080 38 0 _______S___________________________________ slab After this patch: [root@localhost ~]# ./page-types -c /sys/fs/cgroup/user.slice/user-0.slice/user@0.service/ | grep slab 0x0000000000000080 147 0 _______S___________________________________ slab Fixes: 4d96ba353075 ("mm: memcg/slab: stop setting page->mem_cgroup pointer for slab pages") Signed-off-by: Roman Gushchin Cc: Vladimir Davydov Cc: Shakeel Butt Reviewed-by: Shakeel Butt --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ea085877c548..00b4188b1bed 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -476,7 +476,7 @@ ino_t page_cgroup_ino(struct page *page) unsigned long ino = 0; rcu_read_lock(); - if (PageHead(page) && PageSlab(page)) + if (PageSlab(page) && !PageTail(page)) memcg = memcg_from_slab_page(page); else memcg = READ_ONCE(page->mem_cgroup);