Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp38456ybi; Tue, 16 Jul 2019 15:48:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpwVt5diA0Rt4qOfPEA0ZASndeWYKcJFs57ZIdGbZIAAvVDRqUQ7O/OHCOUPvo+e6VgKSG X-Received: by 2002:a63:ff20:: with SMTP id k32mr37016658pgi.445.1563317289944; Tue, 16 Jul 2019 15:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563317289; cv=none; d=google.com; s=arc-20160816; b=clGXVyZKtYG1+a8AqKyTj6r+4EWlReQK0B4bE8FcAZJpBs1Mtu+ojkjf9RyjlMn86+ RiHePRmyOLYNKqv4yn06klnn9KyhN0tdvgwNWSA7Yeu9aFkCaQ4wx8WAa369Q4b7QM1o 4Rl5hhqoLjiu0m7SsiYTPZWKLXxkyEqZbRs9OvLBRGVEsMBTcCNqrtP/k7kBIeZoQJ2R BG710Fczn15/Ged1+CYVOp9RbFtBzQAid/pxoP/IgBJpXBiTbhrwpHXerkmPoMeWMSmK 0dubx7taLgsrOyoAOt6lXIVe4JHqqcM1Q0bcEYMASg4JlpRG0qGUiKW6cxo25kMI3zXq V/Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CHc4daItHr047JAX6t6Ygj5bjbut9nVoR+XN5tnnFNU=; b=SxKpRMW9rV680ljNE23+p3ZNEU1OueeCR76MQFDkLUfNf1Aq89MY4yr40WGPtnc49l DCTVSoqbQ5GT1ie+WkQCyVpoCpD8rnfivswmWTCrS02r1t0J5R1nS+5LapUFReuBXUIU EBDj0O/9UM8SFxPAZg6I8Ee5Tv2ztlnEkXoT6sXwccWzbHH4clp7TyyxaE56Yw8QNk30 2YpswIAPVSmiSAQ9vo8wf/c/Pq/mdT21ZZ9anpI1egkTJRrXr61yHbjTnotwrvp7hoSd U8nBtAwRFWtXN4EPtXMnALVZG12xLfwcame/m8pZaBso4XAd2R1BoaaDZGnAQ4yqeGek +24g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=yWuFBwvC; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si14942777plb.314.2019.07.16.15.47.52; Tue, 16 Jul 2019 15:48:09 -0700 (PDT) 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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=yWuFBwvC; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388804AbfGPWpV (ORCPT + 99 others); Tue, 16 Jul 2019 18:45:21 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:42807 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728235AbfGPWpV (ORCPT ); Tue, 16 Jul 2019 18:45:21 -0400 Received: by mail-oi1-f193.google.com with SMTP id s184so16925123oie.9 for ; Tue, 16 Jul 2019 15:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CHc4daItHr047JAX6t6Ygj5bjbut9nVoR+XN5tnnFNU=; b=yWuFBwvCVvk0bqJ1fWzLXH2rBWx/FNnUSgVei/R5Ar5PeDVXdMfiBgNSwKyI2Ht2KZ LSrvS9RJI96GzWauHQwqt67UNiuc2qCaC5rLLu6VZcHDrxOGzslnCjT2e2qxZ0rFt5D4 luQB1aPKdURv5/cdrcPuQsK1PnBOYpNB/+lfGAI9usbEIeg8N60a+THwW7+dR+yaHIDL ato8gF15L0hsZsqQcCS1O9DFzP76Yf4sNul3sgeiMgJbsOvPqk8MtpsdKqkkgbtDZvw8 qR3YWl8qz/lq/e01gxS90t01/VluVPvoDRQc40zDNvxww8+mVVmAAURMrK3hbtUWN65F /Jgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=CHc4daItHr047JAX6t6Ygj5bjbut9nVoR+XN5tnnFNU=; b=QEpqzosLTgz4ZX13fcM6aPwvy2+Nwgu7nvtweOZcnon0sYphW9qtlBLcM+W9j6cKYL TnoBRQYADv4h9duZyCyg69oqXi4Vza2DShfPp6nsvJLz/5rDDgb/6/7+aOKSdY+dFRxI T/Fmr9Y9Yj9wymQnFay5bS3WXpUcJzt+drXpj0/0W8JbVa+iNM2JFkpgl5HiEx6LpZt6 DqfGe2qXU81UGZ5CstNc5OWr9Kt2EALffmomWCvNA7JhgAFLhG90O5pACUMTZjjg4cA8 aEDH15v73i2NT//GNvr5z/E/MB7hwzecojDXFz/wNinN+nietavHuL/cKgL/3eDoQbRS w5uA== X-Gm-Message-State: APjAAAXoianEMcf8CjCdWtMwd7+i2h/mOdRXDnNdWqp9hxtu+un79kUK xoc4+qlv/8cYV8Egdd9GCdrFzyJbX2ZI7+6O55pSu1vO X-Received: by 2002:aca:1304:: with SMTP id e4mr17392219oii.149.1563317119863; Tue, 16 Jul 2019 15:45:19 -0700 (PDT) MIME-Version: 1.0 References: <20190613045903.4922-1-namit@vmware.com> <9387A285-B768-4B58-B91B-61B70D964E6E@vmware.com> <19C3DCA0-823E-46CB-A758-D5F82C5FA3C8@vmware.com> <20190716150047.3c13945decc052c077e9ee1e@linux-foundation.org> <39E58DBC-C13E-429C-A5FC-8FD80ABBBF55@vmware.com> In-Reply-To: <39E58DBC-C13E-429C-A5FC-8FD80ABBBF55@vmware.com> From: Dan Williams Date: Tue, 16 Jul 2019 15:45:08 -0700 Message-ID: Subject: Re: [PATCH 0/3] resource: find_next_iomem_res() improvements To: Nadav Amit Cc: Andrew Morton , Linux Kernel Mailing List , Linux MM , Borislav Petkov , Toshi Kani , Peter Zijlstra , Dave Hansen , Bjorn Helgaas , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 16, 2019 at 3:29 PM Nadav Amit wrote: > > > On Jul 16, 2019, at 3:20 PM, Dan Williams wr= ote: > > > > On Tue, Jul 16, 2019 at 3:13 PM Nadav Amit wrote: > >>> On Jul 16, 2019, at 3:07 PM, Dan Williams = wrote: > >>> > >>> On Tue, Jul 16, 2019 at 3:01 PM Andrew Morton wrote: > >>>> On Tue, 18 Jun 2019 21:56:43 +0000 Nadav Amit wro= te: > >>>> > >>>>>> ...and is constant for the life of the device and all subsequent m= appings. > >>>>>> > >>>>>>> Perhaps you want to cache the cachability-mode in vma->vm_page_pr= ot (which I > >>>>>>> see being done in quite a few cases), but I don=E2=80=99t know th= e code well enough > >>>>>>> to be certain that every vma should have a single protection and = that it > >>>>>>> should not change afterwards. > >>>>>> > >>>>>> No, I'm thinking this would naturally fit as a property hanging of= f a > >>>>>> 'struct dax_device', and then create a version of vmf_insert_mixed= () > >>>>>> and vmf_insert_pfn_pmd() that bypass track_pfn_insert() to insert = that > >>>>>> saved value. > >>>>> > >>>>> Thanks for the detailed explanation. I=E2=80=99ll give it a try (th= e moment I find > >>>>> some free time). I still think that patch 2/3 is beneficial, but ba= sed on > >>>>> your feedback, patch 3/3 should be dropped. > >>>> > >>>> It has been a while. What should we do with > >>>> > >>>> resource-fix-locking-in-find_next_iomem_res.patch > >>> > >>> This one looks obviously correct to me, you can add: > >>> > >>> Reviewed-by: Dan Williams > >>> > >>>> resource-avoid-unnecessary-lookups-in-find_next_iomem_res.patch > >>> > >>> This one is a good bug report that we need to go fix pgprot lookups > >>> for dax, but I don't think we need to increase the trickiness of the > >>> core resource lookup code in the meantime. > >> > >> I think that traversing big parts of the tree that are known to be > >> irrelevant is wasteful no matter what, and this code is used in other = cases. > >> > >> I don=E2=80=99t think the new code is so tricky - can you point to the= part of the > >> code that you find tricky? > > > > Given dax can be updated to avoid this abuse of find_next_iomem_res(), > > it was a general observation that the patch adds more lines than it > > removes and is not strictly necessary. I'm ambivalent as to whether it > > is worth pushing upstream. If anything the changelog is going to be > > invalidated by a change to dax to avoid find_next_iomem_res(). Can you > > update the changelog to be relevant outside of the dax case? > > Well, 8 lines are comments, 4 are empty lines, so it adds 3 lines of code > according to my calculations. :) > > Having said that, if you think I might have made a mistake, or you are > concerned with some bug I might have caused, please let me know. I > understand that this logic might have been lying around for some time. Like I said, I'm ambivalent and not NAK'ing it. It looks ok, but at the same time something is wrong if a hot path is constantly re-looking up a resource. The fact that it shows up in profiles when that happens could be considered useful. > I can update the commit log, emphasizing the redundant search operations = as > motivation and then mentioning dax as an instance that induces overheads = due > to this overhead, and say it should be handled regardless to this patch-s= et. > Once I find time, I am going to deal with DAX, unless you beat me to it. It turns out that the ability to ask the driver for pgprot bits is useful above and beyond this performance optimization. For example I'm looking to use it to support disabling speculation into pages with known media errors by letting the driver consult its 'badblock' list. There are also usages for passing the key-id for persistent memory encrypted by MKTME.