Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp701506pxy; Wed, 28 Apr 2021 12:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyni+fmlVm0/a4b1eZih2NcnIDjHLESES+Z1fzIvvCs9SRzpU+Q6DB8LJ53nDDYe7m3B41B X-Received: by 2002:aa7:9461:0:b029:27d:cddb:33bc with SMTP id t1-20020aa794610000b029027dcddb33bcmr3289639pfq.75.1619637722829; Wed, 28 Apr 2021 12:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619637722; cv=none; d=google.com; s=arc-20160816; b=PZJlvO3VUW3/Cv0ttXakKCHjDeKMsHW9G2xTe1QPX3DHWpTcoIC+FPxUWCFktp3O4h JhD8y98Mcd6dqTOh+LH08s5C269j8jgNE/kBJZ1JpABJxl/r22UaEsexnoTMqOAc/oTz zk8Zvo4Q8+X8SY0REaYuiVz4CEUL2ZjFn1xl4TTKwbjI1ax1gFGSwSwozld4mX9e1/7d d6U7UQdvy9DNJiZKqaGkRyvIBsyfhAKijrlSLkX01HOu1eJBuSKdf9VOXIzT6T1m0+o8 oXCqeLC/J+TOdxYkRB3KN8J6MI6F19oKACRU1HVhkRwFvuO+zltTzFuMJ9+vynzO/pca d5Aw== 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=4Ofi6Ha3fv3wDQxjDQMVQc5P+260/3F/xgpAfsUQ3bQ=; b=IzNDqMhSWx2PZPYMd9H5bp/ps8SI4BrEGcbW7/Ytid/IEGZYGbJ3CU/I+SmKpxam9E W5Yoo6zmhziOqX8W5FNRoIqtEyuzDvbVzEEjjLjh2fG2D3MF6W8MfgsddBYusoN3V65U paB9CoWRaATXqkk4lHSLbGkOuFwLFnZTgAb5SuQad0hhZnT/qE/NKidXsp3t3jWtXFB4 refJxBNIoI/QyOQ5agzpNM8G2Ay8kNHeiVeO913IT6TXWmrharABV6a36QeiAMjCofEK gfojTihv9L9On5gYSg+FiAplpVKNzpzC76aFsOPNuFHwLyOe1zd072noG4rFlAW0oPTP z7Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ksjBkX+S; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x2si654067pjk.139.2021.04.28.12.21.31; Wed, 28 Apr 2021 12:22:02 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=ksjBkX+S; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239348AbhD1PO4 (ORCPT + 99 others); Wed, 28 Apr 2021 11:14:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:35032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239803AbhD1POw (ORCPT ); Wed, 28 Apr 2021 11:14:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F6F361440 for ; Wed, 28 Apr 2021 15:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619622847; bh=xG7IdJumg4Q9sXJ8+UBUVHjJ+hKMOn7nNzLC0QXPCQU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ksjBkX+Sw4ROm+ksLudw+FDw/+NmY/ywobwWShXfUoBKOOYoAcZR2+k4PZK/f1Xud nvBWDWpDKansHO99Hqz82+rPuGcPJ1gqhWPSAF/EQIUJCU7Wg1G04iFLXW/ZhwdoHZ TrrnV7pFmK2E4W1HDN3JLm+6BvfRmIYJsV/bn4P0MuS+yMc2Xv2ejwz8JlkxzWDvDa wteZ1ICPuRFSz3H+ztxiuhouJLagQoE+mN8K9zxESNDOJIvgfJ/x44AdqCB07sUNKt M2fKPJJS5OkqVbWSpedvwVcoD6DPf9z2Rs/WkiOVH/7U7TgYyZFoBpCIp8EvN3wCbn 4dRUo6q8EyTcA== Received: by mail-ej1-f47.google.com with SMTP id u17so95279932ejk.2 for ; Wed, 28 Apr 2021 08:14:07 -0700 (PDT) X-Gm-Message-State: AOAM532TvmYGqYbp4yIuz0ZYTAm/fyEmRfGcU2qzRZRYT2iTiZihfHD0 x++/7BPJsNa3cpFpATjGCcF3p+QOdcMynDfY7ZO1Og== X-Received: by 2002:a17:906:f742:: with SMTP id jp2mr13124583ejb.199.1619622845689; Wed, 28 Apr 2021 08:14:05 -0700 (PDT) MIME-Version: 1.0 References: <20210407014502.24091-1-michel@lespinasse.org> <20210407014502.24091-14-michel@lespinasse.org> <20210428145823.GA856@lespinasse.org> In-Reply-To: <20210428145823.GA856@lespinasse.org> From: Andy Lutomirski Date: Wed, 28 Apr 2021 08:13:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 13/37] mm: implement speculative handling in __handle_mm_fault(). To: Michel Lespinasse Cc: Andy Lutomirski , Paul McKenney , Linux-MM , Laurent Dufour , Peter Zijlstra , Michal Hocko , Matthew Wilcox , Rik van Riel , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Rom Lemarchand , Linux-Kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 8:05 AM Michel Lespinasse wrote: > > On Wed, Apr 07, 2021 at 08:36:01AM -0700, Andy Lutomirski wrote: > > On 4/6/21 6:44 PM, Michel Lespinasse wrote: > > > The page table tree is walked with local irqs disabled, which prevents > > > page table reclamation (similarly to what fast GUP does). The logic is > > > otherwise similar to the non-speculative path, but with additional > > > restrictions: in the speculative path, we do not handle huge pages or > > > wiring new pages tables. > > > > Not on most architectures. Quoting the actual comment in mm/gup.c: > > > > > * Before activating this code, please be aware that the following assumptions > > > * are currently made: > > > * > > > * *) Either MMU_GATHER_RCU_TABLE_FREE is enabled, and tlb_remove_table() is used to > > > * free pages containing page tables or TLB flushing requires IPI broadcast. > > > > On MMU_GATHER_RCU_TABLE_FREE architectures, you cannot make the > > assumption that it is safe to dereference a pointer in a page table just > > because irqs are off. You need RCU protection, too. > > > > You have the same error in the cover letter. > > Hi Andy, > > Thanks for your comment. At first I thought did not matter, because we > only enable ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT on selected > architectures, and I thought MMU_GATHER_RCU_TABLE_FREE is not set on > these. But I was wrong - MMU_GATHER_RCU_TABLE_FREE is enabled on X86 > with paravirt. So I took another look at fast GUP to make sure I > actually understand it. > > This brings a question about lockless_pages_from_mm() - I see it > disabling interrupts, which it explains is necessary for disabling THP > splitting IPIs, but I do not see it taking an RCU read lock as would > be necessary for preventing paga table freeing on > MMU_GATHER_RCU_TABLE_FREE configs. I figure local_irq_save() > indirectly takes an rcu read lock somehow ? I think this is something > I should also mention in my explanation, and I have not seen a good > description of this on the fast GUP side... Sounds like a bug! That being said, based on my extremely limited understanding of how the common RCU modes work, local_irq_save() probably implies an RCU lock in at least some cases. Hi Paul! --Andy