Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1238542pxb; Fri, 21 Jan 2022 13:05:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZEvvtdscGPeHupCgqXmZv3rQhULnlU5w2pXSzm385JiaEFwBfBZcSi7dJQPrqpw5hOejc X-Received: by 2002:a05:6a00:14cf:b0:4c7:6139:b7b4 with SMTP id w15-20020a056a0014cf00b004c76139b7b4mr2855148pfu.37.1642799122889; Fri, 21 Jan 2022 13:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799122; cv=none; d=google.com; s=arc-20160816; b=SGoK2pV3dm9zd1WmmB2hxWLYCs14u+Qk66e6ZTU8ZBGpgVGTWXinoqqpy5Bs1k9GYF Je1R1etpCMCYXRkTqVfmH6u5KgtLBJwF7yDDyMbdYxx2nNnfh/zHLubcSjfPYPulzrhf B/o388RvIWZu37hZZ0bt121ko0Qub3DBrRx/0P1aiGFNRXrXvSk3EfO/hdv4uas2skl0 aomMcX+hBH8+m/IKc6RGmjOwftou0YR3tPqYPozMPAIfxht2EGwypU0shEplFlGrbFJr 1fFmnxHH0mnR452vChdEKcpcXdUYgEo1FhFhrOi+a5/iljl0b3GLD3M9BjvOnyhMzmSV F47A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HHu2vcmAMjyZdp5l/HlaIQrYa0nqInGDI16V4wpDZxE=; b=fuD2WVwT+/iAiqMuPizHLzhGNLDKMrkF0mp4e42lemh0wSz8iCrhweTpwMx0dwSbkR 0oooNdAiyByyLX8mFVxECZaCLzKwd+HdbZ8iGVBOY3xjtpP67a0hXGCZhN48NNKkZZuR z3Z/6FZMWX6IdR0Z/P34IPGF+ZSSrdzwUB9VYK+Jucz8wOn5cSqMO95l06MEpZRNfhEO gDwnWolnxjo1UxcvbwnrCZaaKFBpZgfjwoJWvtdfxEYnZo+WSwbz6scro2RJ3C2N57CL MvVaWDx1f3W5WeP4uKKY5Aaz833Sxk75WJY315WuKsf4dpxDQKZlXEku7Esu72283HFJ jvjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kM8gwlss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j6si915854plx.362.2022.01.21.13.05.09; Fri, 21 Jan 2022 13:05:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=kM8gwlss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235926AbiATE1z (ORCPT + 99 others); Wed, 19 Jan 2022 23:27:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbiATE1x (ORCPT ); Wed, 19 Jan 2022 23:27:53 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3F7DC061574 for ; Wed, 19 Jan 2022 20:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HHu2vcmAMjyZdp5l/HlaIQrYa0nqInGDI16V4wpDZxE=; b=kM8gwlss+dLkoAyh97n4QxGefg W3ayn98v6j7vqXuUf2HdhOVDe/4Pw1IEe9C6K7cj/vR4tvnJz4g2iWeHPGS5n4uSG4V07nzyZmDmD vlmxnrh51bIlgl62OXy81cYaqtCxb5w19Pa9y2T9y6FtI359xkpwv/yoT5fSHQRLWxAPdafyAjlOR vspfKJn7E3AyAcarQddnd5vKNG50ghktFogDYSAGeCdHJ4HqTYApThMkVc1XtHe2TUkQPFsLatAQy UxqxJ7woCITKqX3ZDz7gde9pPKSX8P6x+2tK9dZzRHaQvq+Wv2FdtHq2jxXBhLl8lXazb4ZY6De8X 8lpHIEIQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAP2t-00DKZK-Vb; Thu, 20 Jan 2022 04:27:36 +0000 Date: Thu, 20 Jan 2022 04:27:35 +0000 From: Matthew Wilcox To: Anshuman Khandual Cc: Yury Norov , Catalin Marinas , Will Deacon , Andrew Morton , Nicholas Piggin , Ding Tianhong , Alexey Klimov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Uladzislau Rezki Subject: Re: [PATCH] vmap(): don't allow invalid pages Message-ID: References: <20220118235244.540103-1-yury.norov@gmail.com> <5b62ed03-8da8-a94d-cc48-a8cac1eae1c9@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b62ed03-8da8-a94d-cc48-a8cac1eae1c9@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 09:07:11AM +0530, Anshuman Khandual wrote: > > > On 1/19/22 10:52 PM, Yury Norov wrote: > >> Why should not this just scan over the entire user provided struct page > >> array and make sure that all pages there in are valid via above method, > >> but in vmap() itself before calling vmap_pages_range(). Because seems > >> like a single invalid page detected in vmap_pages_pte_range() will > >> anyways abort the entire vmap(). This will also enable us to drop the > >> existing NULL check above. > > > > I can do this, but why is it any better than the current approach? > > Because it will just return on the first instance where the valid page > check fails, saving us some CPU cycles and an incomplete mapping ? The valid page check is never intended to fail! If you're worried about the efficiency of doing this, you have seriously confused your priorities.