Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1361519pxb; Fri, 21 Jan 2022 16:31:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLEo76tYB2MYK8JUjQNmpqa6reNa9F3IDk9ahgqFcGmMZOBFESiQLMOA6u5AtmZFNU3FXV X-Received: by 2002:a05:6a00:21c7:b0:4c6:8696:1578 with SMTP id t7-20020a056a0021c700b004c686961578mr5514119pfj.83.1642811500689; Fri, 21 Jan 2022 16:31:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642811500; cv=none; d=google.com; s=arc-20160816; b=jVDhS0/VPE9LzjaxJsuwuRqs8GELtZiT3lRwMjcAeNyLJpy5TT4KV2NGz2NkscOUzv S7HqHMBI2ip/J2KE8V92Am62R0dBmozWAmJHyku5oZRAwwSocJeyfeHLVdzJgtJ5frIm Vqp2Xc4wS7i/b0VYSRv+2HARmIoPOG7L1nQyPv8/Q/tE6bJkPPyIa5mX6OGWOJgtwehA sqqXhvcAciQezmja0ACRZjK8e3TDH/Vus+rtBWfw6oHNDHBc/ZBRzn5QeXeLYbXm+9b0 LKCPqIeTjHmi3MKDBPSdj+9XjOCyFX9K4bq6F3DyWN8GrMSVP3QpbxTuqk4EOnrspC4B kUDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l8EP/XZZ7Adn8RrGBv8m4FZeB3iBzLGLU9rPwYoh5yw=; b=A/lasvetweBFSMKqg++1hhGaxo75wvoJDoQi39v5iPscES29sADB/1NRbKSxmDo7GF THuVi+7fnCdmQ9W86A96y3rQ1NyitIJ3VPnORffRv/6MCs38zQEg6f4Y1bcVtA4IGTt5 ZKb6ES3CXCwV5t91Qh2aiL8X/SikGNOSc6HPqWc0nOPLfrXZbFrDduG91ugeg3lrpJNK DIrEHtOJGqzGdmov4+uZBTqrV5F45eLZu+txmGDgkq0iVMp5WE3IxTOgCugFCB6pB/hk eM0BsNj1Mvkh04AA04Z95LjlSRqtiFB7gyea2jq+np0XYnw8oLtIEmxudBBpzph76s9o EB5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jx0PtvGy; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si8629568pla.241.2022.01.21.16.31.29; Fri, 21 Jan 2022 16:31:40 -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=@gmail.com header.s=20210112 header.b=Jx0PtvGy; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232120AbiAUC4l (ORCPT + 99 others); Thu, 20 Jan 2022 21:56:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbiAUC4h (ORCPT ); Thu, 20 Jan 2022 21:56:37 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19860C061574 for ; Thu, 20 Jan 2022 18:56:37 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id w12-20020a17090a528c00b001b276aa3aabso12455116pjh.0 for ; Thu, 20 Jan 2022 18:56:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l8EP/XZZ7Adn8RrGBv8m4FZeB3iBzLGLU9rPwYoh5yw=; b=Jx0PtvGyAcCNi+Gk6w9sFCqPBN9EXeSFnV2eHAckQsddN3rd6m/i8MAeiAfnTaWRHD 7MwopjlDrvqrlkbsGNtOaWeZr8vw12Oi5AUsgVREu0EQ+zWmmaiMDU2PbXfDLAlQ9/T8 uD80nzTgu71SJkXDlE9DjLbr8Hqv2wyJ9X3XyUMGtGe18FHc3UIw/H5JxqZk++tlsfB9 W/j+12yicImVTjUd5EUHmUVEWtDCofM3gI49gA8541iTX6YswWxnbXqjW21N6VkDmoim M9gDoCysk9QpNoI6LQyis/9hucoJ7tM6rNDO+DJUdrQNCbtm8sAojZx/8zzL3pb25Pwp apmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=l8EP/XZZ7Adn8RrGBv8m4FZeB3iBzLGLU9rPwYoh5yw=; b=JtJj9jUsZfajVOeOPiFLWqESwiHNELRqBRdnfvTSWqCDd4B1fFud3mYuroDNZiDX1x DPK8K/HOx/SewqBxB54T4sHOASTkl3RgFUUHyHhykR31Zy8deVcSAd26GAeqhN1LlIvw CXOgbXz1xijl3+NHX9QJIkzef9d85qWUfZcE0wqDXsEe3mEyoVJHvDSk+4eDKxyp97TM dp0xMqRMOruxd6MPG3DZ0qZAusCC67TOHYk2yTP/7uWPVrO1Gefa7gnyhPp1K6dAT0dc KJiivjFVVqFn/t9Q1uYY0euPXDqI8gzedTnkfV8hH2WSyUwiR5vHV2RYdunuXYF0JZ+K PM7w== X-Gm-Message-State: AOAM532F/x4g/NaEziomd4QTcZtPMPkZZ+bwPnxn2PbezssygiAA3Mwu dQCVrzTS4O5OZQjgQblJJhNioQJfu3pW/7HWMSE= X-Received: by 2002:a17:90a:9104:: with SMTP id k4mr14427919pjo.87.1642733796533; Thu, 20 Jan 2022 18:56:36 -0800 (PST) MIME-Version: 1.0 References: <20220118235244.540103-1-yury.norov@gmail.com> <5b62ed03-8da8-a94d-cc48-a8cac1eae1c9@arm.com> In-Reply-To: <5b62ed03-8da8-a94d-cc48-a8cac1eae1c9@arm.com> From: Yury Norov Date: Thu, 20 Jan 2022 18:56:16 -0800 Message-ID: Subject: Re: [PATCH] vmap(): don't allow invalid pages To: Anshuman Khandual Cc: Matthew Wilcox , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 19, 2022 at 7:37 PM 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 ? This should normally never happen, that's why warn_on() is there. If it happens, there is a serious problem, and the code must be fixed. So, no CPU cycles saving in real life.