Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753085AbbFZPSp (ORCPT ); Fri, 26 Jun 2015 11:18:45 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:58170 "EHLO e06smtp10.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751932AbbFZPSh (ORCPT ); Fri, 26 Jun 2015 11:18:37 -0400 X-Helo: d06dlp03.portsmouth.uk.ibm.com X-MailFrom: dingel@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Date: Fri, 26 Jun 2015 17:18:29 +0200 From: Dominik Dingel To: nick Cc: akpm@linux-foundation.org, mhocko@suse.cz, riel@redhat.com, kirill.shutemov@linux.intel.com, hannes@cmpxchg.org, dave@stgolabs.net, koct9i@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Add error check after call to rmap_walk in the function page_referenced Message-ID: <20150626171829.4b8651ed@BR9TG4T3.de.ibm.com> In-Reply-To: <558D660B.7070102@gmail.com> References: <1435282597-21728-1-git-send-email-xerofoify@gmail.com> <20150626155614.04bffed1@BR9TG4T3.de.ibm.com> <558D660B.7070102@gmail.com> Organization: IBM X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15062615-0041-0000-0000-000004BD6996 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3180 Lines: 81 On Fri, 26 Jun 2015 10:47:39 -0400 nick wrote: > > > On 2015-06-26 09:56 AM, Dominik Dingel wrote: > > On Thu, 25 Jun 2015 21:36:37 -0400 > > Nicholas Krause wrote: > > > >> This adds a return check after the call to the function rmap_walk > >> in the function page_referenced as this function call can fail > >> and thus should signal callers of page_referenced if this happens > >> by returning the SWAP macro return value as returned by rmap_walk > >> here. In addition also check if have locked the page pointer as > >> passed to this particular and unlock it with unlock_page if this > >> page is locked before returning our SWAP marco return code from > >> rmap_walk. > >> > >> Signed-off-by: Nicholas Krause > >> --- > >> mm/rmap.c | 10 +++++++++- > >> 1 file changed, 9 insertions(+), 1 deletion(-) > >> > >> diff --git a/mm/rmap.c b/mm/rmap.c > >> index 171b687..e4df848 100644 > >> --- a/mm/rmap.c > >> +++ b/mm/rmap.c > >> @@ -814,7 +814,9 @@ static bool invalid_page_referenced_vma(struct vm_area_struct *vma, void *arg) > >> * @vm_flags: collect encountered vma->vm_flags who actually referenced the page > >> * > >> * Quick test_and_clear_referenced for all mappings to a page, > >> - * returns the number of ptes which referenced the page. > >> + * returns the number of ptes which referenced the page.On > >> + * error returns either zero or the error code returned from > >> + * the failed call to rmap_walk. > >> */ > >> int page_referenced(struct page *page, > >> int is_locked, > >> @@ -855,7 +857,13 @@ int page_referenced(struct page *page, > >> rwc.invalid_vma = invalid_page_referenced_vma; > >> } > >> > >> + > > > > unnecessary empty line > > > >> ret = rmap_walk(page, &rwc); > >> + if (!ret) { > >> + if (we_locked) > >> + unlock_page(page); > >> + return ret; > >> + } > > > > I don't see why the function should propagate the rmap_walk return value. > > rmap_walk will not set pra.referenced, so that both callers just skip. > > > > What is the purpose of the given patch? Do you have any real case introducing such code, > > which is imho incomplete as all callers need to take care of the changed return value! > > > There is only one caller that needs to be moved over if this case is put in. Further more > do we care if executing rmap_walk fails as if it does this means we were unable to execute > the function page_referenced one on the rmap_walk_control structure rwc and this can be > a issue in my option, if not then we can just remove the ret variable and execute rmap_walk > without checking it's return value. > Cheers Nick Let me rephrase: what will happen after you return ret? What will: - shrink_active_list - page_check_references now do? For your second thinking it would be good to check how and why ret was introduced? git log -L '/int page_referenced(/',/^}/:mm/rmap.c -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/