From patchwork Thu Oct 17 16:42:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11196389 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 C316A139A for ; Thu, 17 Oct 2019 16:42:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D85B21848 for ; Thu, 17 Oct 2019 16:42:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="e0lDytQZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D85B21848 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 907718E000D; Thu, 17 Oct 2019 12:42:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8B8B48E0003; Thu, 17 Oct 2019 12:42:52 -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 7D00A8E000D; Thu, 17 Oct 2019 12:42:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id 59A898E0003 for ; Thu, 17 Oct 2019 12:42:52 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id F0643181AEF1E for ; Thu, 17 Oct 2019 16:42:51 +0000 (UTC) X-FDA: 76053845742.24.play99_532e0ce6eae35 X-Spam-Summary: 75,0,0,8aac0e2376ae775c,d41d8cd98f00b204,prvs=51939537e3=songliubraving@fb.com,:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:matthew.wilcox@oracle.com:kernel-team@fb.com:william.kucharski@oracle.com:kirill.shutemov@linux.intel.com:willy@infradead.org:songliubraving@fb.com,RULES_HIT:41:355:379:541:800:960:966:968:973:988:989:1260:1261:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3352:3608:3865:3868:3870:3871:3872:3874:4250:4321:4385:5007:6119:6261:6653:7576:8603:8957:10004:10400:11026:11473:11658:11914:12043:12296:12297:12555:12679:12895:13069:13141:13230:13311:13357:14096:14097:14181:14394:14721:21080:21451:21627:30054:30064,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ff,MSBL:0,DNSBL:infradead.org-sh.dbl.urbl.hostedemail.com-127.0.0.175,Custom_rules:0:0:0,LFtime:17,LUA_SUMMARY:none X-HE-Tag: play99_532e0ce6eae35 X-Filterd-Recvd-Size: 4076 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Oct 2019 16:42:51 +0000 (UTC) Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9HGUWeY013440 for ; Thu, 17 Oct 2019 09:42:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=mxxwNAzZrls6tfJ060ELcx7ju3XNeq5KMWMl6d4cOI4=; b=e0lDytQZcDJTqZKRJP4dEBlfVzKaPES42qqQyByt/YglezV5nzbEQ7GxkLkVVMqLGQJ7 yBYOWn3C3ZJ9TguQ0tDGt9vsviD7RW8Y/tVRllI8X6kWSz7sAqmBSPL5TYbSgF2tYNkc mU0pyjwGiHfVLK8GWk5ovDIgHys7upo1a6s= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2vpcs13sdr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 17 Oct 2019 09:42:50 -0700 Received: from 2401:db00:2120:81ca:face:0:31:0 (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Thu, 17 Oct 2019 09:42:48 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 5892662E1477; Thu, 17 Oct 2019 09:42:47 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , Matthew Wilcox , Song Liu Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v2 3/5] mm: Support removing arbitrary sized pages from mapping Date: Thu, 17 Oct 2019 09:42:20 -0700 Message-ID: <20191017164223.2762148-4-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017164223.2762148-1-songliubraving@fb.com> References: <20191017164223.2762148-1-songliubraving@fb.com> 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-17_05:2019-10-17,2019-10-17 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 spamscore=0 mlxlogscore=603 mlxscore=0 phishscore=0 suspectscore=2 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910170149 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: From: William Kucharski __remove_mapping() assumes that pages can only be either base pages or HPAGE_PMD_SIZE. Ask the page what size it is. Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS") Signed-off-by: William Kucharski Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Song Liu Acked-by: Yang Shi --- mm/vmscan.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index c6659bb758a4..f870da1f4bb7 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -932,10 +932,7 @@ static int __remove_mapping(struct address_space *mapping, struct page *page, * Note that if SetPageDirty is always performed via set_page_dirty, * and thus under the i_pages lock, then this ordering is not required. */ - if (unlikely(PageTransHuge(page)) && PageSwapCache(page)) - refcount = 1 + HPAGE_PMD_NR; - else - refcount = 2; + refcount = 1 + compound_nr(page); if (!page_ref_freeze(page, refcount)) goto cannot_free; /* note: atomic_cmpxchg in page_ref_freeze provides the smp_rmb */