From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by kanga.kvack.org (Postfix) with ESMTP id 099C26B0038 for ; Thu, 2 Oct 2014 08:41:19 -0400 (EDT) Received: by mail-vc0-f175.google.com with SMTP id id10so1285386vcb.6 for ; Thu, 02 Oct 2014 05:41:19 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id jq10si2886295vdb.75.2014.10.02.05.41.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Oct 2014 05:41:18 -0700 (PDT) Date: Thu, 2 Oct 2014 14:40:43 +0200 From: Andrea Arcangeli Subject: Re: [PATCH 2/4] mm: gup: add get_user_pages_locked and get_user_pages_unlocked Message-ID: <20141002124043.GC2342@redhat.com> References: <1412153797-6667-1-git-send-email-aarcange@redhat.com> <1412153797-6667-3-git-send-email-aarcange@redhat.com> <20141001155159.GA7019@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Andres Lagar-Cavilla Cc: Peter Feiner , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Gleb Natapov , Radim Krcmar , Paolo Bonzini , Rik van Riel , Peter Zijlstra , Mel Gorman , Andy Lutomirski , Andrew Morton , Sasha Levin , Jianyu Zhan , Paul Cassella , Hugh Dickins , "\\Dr. David Alan Gilbert\\" On Wed, Oct 01, 2014 at 10:06:27AM -0700, Andres Lagar-Cavilla wrote: > On Wed, Oct 1, 2014 at 8:51 AM, Peter Feiner wrote: > > On Wed, Oct 01, 2014 at 10:56:35AM +0200, Andrea Arcangeli wrote: > >> + /* VM_FAULT_RETRY cannot return errors */ > >> + if (!*locked) { > >> + BUG_ON(ret < 0); > >> + BUG_ON(nr_pages == 1 && ret); > > > > If I understand correctly, this second BUG_ON is asserting that when > > __get_user_pages is asked for a single page and it is successfully gets the > > page, then it shouldn't have dropped the mmap_sem. If that's the case, then > > you could generalize this assertion to > > > > BUG_ON(nr_pages == ret); Agreed. > > Even more strict: > BUG_ON(ret >= nr_pages); Agreed too, plus this should be quicker than my weaker check. Maybe some BUG_ON can be deleted later or converted to VM_BUG_ON, but initially I feel safer with the BUG_ON considering that is a slow path. > Reviewed-by: Andres Lagar-Cavilla Thanks! -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org