Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4527874imj; Tue, 12 Feb 2019 18:35:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IYma/G1+9IAMz2jJZb0a9qnhIigWKN76qVy3hxRVBZlSTEJFXRZOyStTNRXrqkCTnEa9X3C X-Received: by 2002:a17:902:ba8e:: with SMTP id k14mr7216494pls.219.1550025352845; Tue, 12 Feb 2019 18:35:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550025352; cv=none; d=google.com; s=arc-20160816; b=tr8B+GR4auy8MChpxqQ8GNLs2Ad0KY974DQrK+AnM4yrYT0sABHBLd3MbPDIGwkbES 6NIxMcUJ3HphDygf12A2zwlPP6ys+4AIHGGnn4HDkk0VzdP3zP4350c3tIZKQEPF6x1X Lj8dBmciDB9L4CWocZzWo5lxorFrnMGJB3miELRyq/ldFt57h/4eWt6u63XJz8DzZuvP XUSerIAe5jjq2E5Wh2JUnlnPPcCjIT0XEt1+SD2Eqv+r2EEGntLU/qfOvnJd91tXz85x qADv0wjzvMWtq1bQQILdpgKRU3CxJW1bdShX3qXSyDUdLkTanPS3T2hG9vZMaFzUcX9/ 1JIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QQqVRIzi2ZKQ1+x3//wGskAucMWO5ZOTt+7fEHwsmFU=; b=cJ3iHQnOnyVCUYIuhb0ofFuBML8q/XOOHO0qbcfJLzlN8hZk9/V3ZBZVZU7CvcpL2W lHjVTt9j1WeL1hEV+DHP/Sl5xQkO6yqeG5YBRtPS4eZRxLVNQ/z3AE75TOYcPtvAnPdk hZAHWE6wy6IUmvv6VZSj6UvpqYZHvOYi0TNbktXEpFTkttqhYHmtwBTbeu/UQunOfTRZ pFDpTLpGyZuW9CK68kHQLgQkEl2tZjucae/zc+fnpPXGqSdI22bM2z/DBHALYkhYx+TB 3bZ6epDSFWT0xtzQJRaPH3Uh7IY8D7PfEtAVRDno8+sMARFe4GDCZhTwzidjdVa2yULD 02kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BQFE2J2G; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c17si8205337pfb.81.2019.02.12.18.35.37; Tue, 12 Feb 2019 18:35:52 -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=@google.com header.s=20161025 header.b=BQFE2J2G; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732440AbfBLX5s (ORCPT + 99 others); Tue, 12 Feb 2019 18:57:48 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:55152 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729354AbfBLX5r (ORCPT ); Tue, 12 Feb 2019 18:57:47 -0500 Received: by mail-it1-f194.google.com with SMTP id p11so1230854itf.4 for ; Tue, 12 Feb 2019 15:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QQqVRIzi2ZKQ1+x3//wGskAucMWO5ZOTt+7fEHwsmFU=; b=BQFE2J2GcTdoaR3dWyKYvqUhQ4t/A/HraworagwibSGxHKTkRD64ZPvTAUon4dHuoh bjlizUafHQYjZVulL0a9//I1yftb8NaJi5qd3ks4AMtLA2jByOvIwlepINm6q9YVD8og 1UB7Ui4JFXUcniZmwHGeq/vueLJGWt6qpSqP1xklyDXbS6Y4U92TCwwKXxezi65RRXKg FqkRTJaS1yFJVDvXyvoA6RxmNm7c8UJdW7Bv+QVy5Qe0o7SOLkA9huuJ9nCuwku6EqO3 tVL5V9F5Lj6u7SEkAaz0bFSCuNtJKITHzhC1n2hmxkewN3+0+iX4JILMeaRxLu9D9Lb3 +uzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QQqVRIzi2ZKQ1+x3//wGskAucMWO5ZOTt+7fEHwsmFU=; b=PlJK7gqO+udiLHcQRSW/TrRs1iO+tcroXp4Da16nMISz5YXgXlgbdLeuGp8NS5+4Mo 6y8XbZ3TDBWrz4Tc5CtUkqZylo1MPnNnmYo9Pa0Es+jOpHzEgWXoWj7ZyiP0c0JC/Jjn 7h4GhSagZEvdUHIv+fahr7bOoLb+Fy8Ozt6SKraWqN3qPhrMnlztbdVG/zodTVA5BI7L PLhailHgNreGmJ8tJFtTwoLxfOovJMQR49jTyDrKHutmDzOltiGPEwhUb7hzn/YPFOjH yIozl5GGI23DIgGCrBEhphFD/y570SUXIhJfTa5D39OVUgdyJ+B3rxV6Hq/fFsa7v2sJ qi5w== X-Gm-Message-State: AHQUAubNgOugqvg4o2cX9xO5Mzma06jMsUhN6iD0Wxbg8dJES93Iw7LE wfSmtheCcxjaC+nQ3H39Fm2afw== X-Received: by 2002:a24:9b89:: with SMTP id o131mr706270itd.41.1550015866451; Tue, 12 Feb 2019 15:57:46 -0800 (PST) Received: from google.com ([2620:15c:183:0:a0c3:519e:9276:fc96]) by smtp.gmail.com with ESMTPSA id k26sm3462792iol.14.2019.02.12.15.57.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Feb 2019 15:57:45 -0800 (PST) Date: Tue, 12 Feb 2019 16:57:43 -0700 From: Yu Zhao To: William Kucharski 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 Subject: Re: [PATCH] mm/shmem: make find_get_pages_range() work for huge page Message-ID: <20190212235743.GB95899@google.com> References: <20190110030838.84446-1-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 10, 2019 at 04:43:57AM -0700, William Kucharski wrote: > > > > On Jan 9, 2019, at 8:08 PM, Yu Zhao wrote: > > > > 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. > > > > Signed-off-by: Yu Zhao > > --- > > mm/filemap.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > 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, > > > > pages[ret] = page; > > if (++ret == nr_pages) { > > - *start = page->index + 1; > > + *start = xas.xa_index + 1; > > goto out; > > } > > continue; > > @@ -1850,7 +1850,7 @@ unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, > > > > pages[ret] = page; > > if (++ret == nr_pages) { > > - *index = page->index + 1; > > + *index = xas.xa_index + 1; > > goto out; > > } > > continue; > > -- > > 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. I'm not sure how this could be more readable, and it sounds independent from the problem the patch fixes. > 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. It seems to me it's pefectly fine to use fields of xas directly, and it's being done this way throughout the file. > Does anyone else have a feeling one way or the other? I could be persuaded either way.