Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1231008ybg; Fri, 18 Oct 2019 14:14:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvhZ3K5r5ZDix19GxC2e8paibSzO+PovMirpuAT4EJqhmSfljbNJ24Q0ZUPSc4DnEBSkkN X-Received: by 2002:a17:906:c2c1:: with SMTP id ch1mr10376871ejb.321.1571433240242; Fri, 18 Oct 2019 14:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571433240; cv=none; d=google.com; s=arc-20160816; b=kGh/v+RoL29ULg8ZaXMze49uHZfigpI/yGBQeRg76JxwAzz7P9nDlnAslBxy0xXADp t9QbV81vefEW/VpxQor2b2hcrQ4HSEZU8rZ5pgrNzIkgh6LLejjdjNSryZNSekDUBV1d s/lBKEGEYxeJ2YvwxOamlLSlmihy8IYWu4HLUNWtB0HvIidGPAH5uESz0tVxSZq2Qno/ jnLnZr18Qxj8a7RN4Bor8ZoLn6nzEDerfsQhYMpNbvoS75NjCbgmXdEMh52DhGwffqAp PJNc4YUu9KAFqBQh6n09wmW8xyjVRx+cZ2bWiCA+cUM3PusvCPSWOLFZwuxYKpSdTnEL iZHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:smtp-origin-cluster:cc:to :smtp-origin-hostname:from:smtp-origin-hostprefix:dkim-signature; bh=mxxwNAzZrls6tfJ060ELcx7ju3XNeq5KMWMl6d4cOI4=; b=bDgpjnAPD03Mjt8xAPMIhcDsKnBPVctMPKYyFyVB6sFLyJSUgUFMKINFC2kOLl6E4Y 7Jy4yinsj7kQ6BEMrggXLh/+hAoWds9N8bzli7lH84U2A/OigEEDib71B+LoNCftc184 X6K2baYvZbpKk1wD4k9SDMuwk2eRg8eHhxGh98kdeGyT1tiwqMtPdKxYhcWJrFMzcPCo fNY0qW9Q0Gs72adu5gOUeZphWbkNuQq78gqaYVZm8VUVUWiioDQt8xUEVLqErQKDBL2s CFyW5FG9P08S894gikb8pjGi0zs3NIXagwA3S3ooorjiV9rP1ARKfQj+OktswOwi/+ZW wEQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=e0lDytQZ; 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=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si4052147ejw.276.2019.10.18.14.13.37; Fri, 18 Oct 2019 14:14:00 -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=@fb.com header.s=facebook header.b=e0lDytQZ; 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=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502644AbfJQQmx (ORCPT + 99 others); Thu, 17 Oct 2019 12:42:53 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:12450 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502698AbfJQQmv (ORCPT ); Thu, 17 Oct 2019 12:42:51 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9HGV6r4003253 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 2vp5k0e28t-1 (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::130) 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:49 -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 Content-Type: text/plain 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 spamscore=0 suspectscore=2 bulkscore=0 clxscore=1015 mlxscore=0 mlxlogscore=607 impostorscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910170149 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 */ -- 2.17.1