Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1862101imu; Thu, 10 Jan 2019 04:23:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN4kcASqts2h7rhRXEJ3KzwW6sjYL+qbhlEv8UNYfbLiN9H5XmojZM6RovHxZj4ZwSWeRi9F X-Received: by 2002:a63:9a52:: with SMTP id e18mr9161152pgo.14.1547123034841; Thu, 10 Jan 2019 04:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547123034; cv=none; d=google.com; s=arc-20160816; b=zOHuT0abWEy7oFAdbqFTZ7P5cLBPh7zKtq/9XsvM3so0kh+KC/v6v9eKlvcR4wFols HdRkfKE1iH2b0ZzsoVgZ+qhXKx9vQDDLK8Ld9T3K9kr0QNk9Kw7Xzi6TSrEwebkVxjHk VFo2Zj9zl6vTV48V2Lge9sQVzWiM0kZsA/34TOcfmn9WpmN9dE0KqaMT4gLSJUmjf7eF tp4A0L2wgWK4FApzM2Pg37KEw/R6jroqFSvm/y/lgEefyrR/17FrCUk30Bwu8Ab/GNTc X6R4w/3uE1oZTO9sDM996fzPHNmQYE3Pcrqb7dudMKd0q7pyAvizSh1nZaVFfB3tSC8b /ULA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=n3s1ZAdLR0jBpj/R+OdXMda6knsYE7fX2xsscIoqQG0=; b=D/dcryCGte/Q7KIyIYToI+eG9vfscEmp7esrW1SZ4FjBNqRUwXjLYz0HJ+hmoW4Ahs hK61GPG5/QnPQJZZp78o6pXbilFwUbMQt79AVDgnR6Ffnqzx8X10kd2sAaZw/73lg6jf TuycbNRd10Alc+dVxdszfMdGjheglyIg/Gstp2B4g2K77TJp9f7A20kS25Goi5jTkAi5 fjWOnsK02ZbB1gjyfYrmzPR+B6o3I3rvx2ouyL8/5QriY7H8ZiC7aXIQ28Ac9g3tEkA3 kCBPQRKk6xcIltSa3uri2UmXsyg04s4RUhdX4Lpmkv5KXmkDQdnaTgLQLtOAZDTxmBw/ 61Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ya0YYmWd; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c76si10428628pga.70.2019.01.10.04.23.39; Thu, 10 Jan 2019 04:23:54 -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=@oracle.com header.s=corp-2018-07-02 header.b=ya0YYmWd; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbfAJLo2 (ORCPT + 99 others); Thu, 10 Jan 2019 06:44:28 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:38788 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727938AbfAJLo1 (ORCPT ); Thu, 10 Jan 2019 06:44:27 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0ABhZga110788; Thu, 10 Jan 2019 11:44:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2018-07-02; bh=n3s1ZAdLR0jBpj/R+OdXMda6knsYE7fX2xsscIoqQG0=; b=ya0YYmWdSdbwkeiN3vQqhPLTmCN/rrPap5uTbdpdXZ/U3hjRgwDZ09hZQ2xD5LI/tp6U uA1V3GJQ6mph1WBQW6ko8S6+2RLerF7sIC4e6V4adeIO9+rxJTD5ChBwyd60m3lifuqD Y3Fo11isnltMnMxuc9guHSfil7Sx6LrXOdo4JOvW+2ePL49fJuQ4YF0ix7VSKxzjNYUR e2e9wq33t+4epzNRzb+ffUd5F01BIxKT3bPQGMUgwZPyIsl30+fx7YpqE7vkLwJYiYoQ GdlHMXOmAxsH1ZaXvEi/Tse2AAd0ByFxbevzZchC1N7xjeCXiJ4rBBnzUXemL80aytFH Wg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2ptn7r6j8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 11:44:06 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0ABi5Yt003163 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jan 2019 11:44:05 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0ABi1gt007674; Thu, 10 Jan 2019 11:44:01 GMT Received: from [192.168.0.110] (/73.243.10.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Jan 2019 03:44:00 -0800 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH] mm/shmem: make find_get_pages_range() work for huge page From: William Kucharski In-Reply-To: <20190110030838.84446-1-yuzhao@google.com> Date: Thu, 10 Jan 2019 04:43:57 -0700 Cc: Matthew Wilcox , Andrew Morton , Amir Goldstein , Dave Chinner , "Darrick J . Wong" , Johannes Weiner , Souptick Joarder , Hugh Dickins , "Kirill A . Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20190110030838.84446-1-yuzhao@google.com> To: Yu Zhao X-Mailer: Apple Mail (2.3445.102.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9131 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901100097 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jan 9, 2019, at 8:08 PM, Yu Zhao wrote: >=20 > find_get_pages_range() and find_get_pages_range_tag() already > correctly increment reference count on head when seeing compound > page, but they may still use page index from tail. Page index > from tail is always zero, so these functions don't work on huge > shmem. This hasn't been a problem because, AFAIK, nobody calls > these functions on (huge) shmem. Fix them anyway just in case. >=20 > Signed-off-by: Yu Zhao > --- > mm/filemap.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/mm/filemap.c b/mm/filemap.c > index 81adec8ee02c..cf5fd773314a 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -1704,7 +1704,7 @@ unsigned find_get_pages_range(struct = address_space *mapping, pgoff_t *start, >=20 > pages[ret] =3D page; > if (++ret =3D=3D nr_pages) { > - *start =3D page->index + 1; > + *start =3D xas.xa_index + 1; > goto out; > } > continue; > @@ -1850,7 +1850,7 @@ unsigned find_get_pages_range_tag(struct = address_space *mapping, pgoff_t *index, >=20 > pages[ret] =3D page; > if (++ret =3D=3D nr_pages) { > - *index =3D page->index + 1; > + *index =3D xas.xa_index + 1; > goto out; > } > continue; > --=20 While this works, it seems like this would be more readable for future = maintainers were it to instead squirrel away the value for *start/*index when ret was zero on = the first iteration through the loop. Though xa_index is designed to hold the first index of the entry, it = seems inappropriate to have these routines deference elements of xas directly; I guess it depends on = how opaque we want to keep xas and struct xa_state. Does anyone else have a feeling one way or the other? I could be = persuaded either way.=