Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3760098ybz; Mon, 27 Apr 2020 23:13:12 -0700 (PDT) X-Google-Smtp-Source: APiQypIn4m7Aqcn0ACM2+HFfPBn/OitvQU5UzQ9Iqg1qBDq0u3IZs9oRZh2O9LJPeU/CqRDlngNL X-Received: by 2002:a05:6402:b4e:: with SMTP id bx14mr22048771edb.41.1588054392019; Mon, 27 Apr 2020 23:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588054392; cv=none; d=google.com; s=arc-20160816; b=VwG3gtl+zTa4lQMRduPe+GlACpYDCeUt0yHUjE9ta/1fFzu4uzuRbommWgckXanaF2 fiyuIcfIKjIpzvyFkZeQTy4MqT/0/7g3WChtWGQG/bhK79r8SGj5gibhNw/X/DHeSk/Y e8lzaFHx43eLPB+nCxxYeXdLPf0ZrjSpwsqyBNxLZWn/8dxiHjvNH5bBsTjp9nHsrzMa cdSFPAUaHw+trGmA1/ZctG/TC2qGGX4e8HdsWxy4JZ1Dot7x5mT93CBXQ84rX3fMWTAT jStrR4UZfNTEKfQ/HMhD9km4GmnTgd0p3QMb286G5/3gw+8yM8O4wbfrRWceeegnBbCG 3jqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fjR2WXsg1WuSqX8WD5c+nhnalPJJVRAV+Xn9CSGG1bY=; b=lKAKet7R06EnhNJdBG3pIkPA+aPFPO10o47dUJ0QhZocKga7A6QMy+jyUQyyuO7nYg auYtCqlUOwnkxnV8MFBGeIXgVR5yCBy0Oiabk/HdLL5kIUKM6uJWOQsHwrAuXk38UNXI HgIkopR4K/MpciHajuJc22PKqiwOytljvP6YMH3+nBIgYqpOWpqbfaBNNYk3fDp17xvH +EOv+UjelWrEqN93QVo91/y89odzeweF1ZQxbUO5ytMf4QPP/AvWTz2/x6834Qi8e9Ue xxb7G9tH2IG0C7MKnWMr/2J8f1BGsYrgJ9QYHsBeRPu9lOaxr13WMiCgmU4F3CuCrR1J bVXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cdP0uVyD; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si1003164edq.231.2020.04.27.23.12.48; Mon, 27 Apr 2020 23:13:12 -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=@google.com header.s=20161025 header.b=cdP0uVyD; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726399AbgD1GLV (ORCPT + 99 others); Tue, 28 Apr 2020 02:11:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726338AbgD1GLU (ORCPT ); Tue, 28 Apr 2020 02:11:20 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F58BC03C1AC for ; Mon, 27 Apr 2020 23:11:19 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id m2so15853560lfo.6 for ; Mon, 27 Apr 2020 23:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fjR2WXsg1WuSqX8WD5c+nhnalPJJVRAV+Xn9CSGG1bY=; b=cdP0uVyDLEuTHWB46kef943mTKZiv/Grb+3pidmYUxbnYjhqmBibE45csv9aQ88lot AJ3IDfIwUFyKZ0ltlC/7Xz/eIBrBQ9fKuiYosWuO9jxHiT7plltOgrcHcyVpxe7QmbFJ +/ZAj1QUE0+7MbjnRNVVxQdmpxWa3++ZAydGa9ZaoAwMf5FQMxsgbkOQjpNYPiBk1sY+ 4yiGOkjuYSnheFG1MggDO6unAQSkGnM4raGCF4V8kQa2tBeFbthnB+CXJOmDktWBOEtl eTb5TN7/Nnq4dr6LqUU6zAA7IbwWt3mzS4YUp1+NK/1MBrYrdLqkTHc4pCWe0R/ARh+9 +0pA== 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; bh=fjR2WXsg1WuSqX8WD5c+nhnalPJJVRAV+Xn9CSGG1bY=; b=MjSNW8ZeZMsj/zIN4GCHfcjtt4oLFdZ8Oq+wOmC5YnooRrMHLw6W4bHZVjF96oCA8l qlY+T5Kq++PJtaQP+ltU/mqMwf+ari2ULterFexBv8tM5e7o2aFH6luMTQDVXwtRfHDY Cx+716tXsupLYt9pjweOkGRQUIRaI1Q+ZEt3f8xkz52zlClRJKPQCea9q2Kb9cLv540s nd9TuZKA2M4HYQNmJ7eUWuxURVm04pSNL9TF1Bq353LOP/M8xI09pwxqBFog62oJ+B/W MFm5YiUpcnJJT2sqbaKpnHW2GhbBwPhE5hQLgNpF0Oo5gM4ATdvZo8sIdlJ8Z3uZzOzr 5T1A== X-Gm-Message-State: AGi0Pub6WuS1jBL2CICFASs0JnUaI5HCisykuOV8O5egXYeJoypKpOkZ psIOrI+5fWDlqop+hT1oVh25dIRyu9QV12ahMH4B5z3eVX0= X-Received: by 2002:a19:e04a:: with SMTP id g10mr17744131lfj.164.1588054277719; Mon, 27 Apr 2020 23:11:17 -0700 (PDT) MIME-Version: 1.0 References: <20200428032745.133556-1-jannh@google.com> <20200428032745.133556-6-jannh@google.com> In-Reply-To: From: Jann Horn Date: Tue, 28 Apr 2020 08:10:51 +0200 Message-ID: Subject: Re: [PATCH 5/5] mm/gup: Take mmap_sem in get_dump_page() To: Linus Torvalds Cc: Andrew Morton , Christoph Hellwig , Linux Kernel Mailing List , Linux-MM , linux-fsdevel , Alexander Viro , "Eric W . Biederman" , Oleg Nesterov , Russell King , Linux ARM , Mark Salter , Aurelien Jacquiot , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Rich Felker , Linux-sh list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2020 at 5:50 AM Linus Torvalds wrote: > On Mon, Apr 27, 2020 at 8:28 PM Jann Horn wrote: > > > > Properly take the mmap_sem before calling into the GUP code from > > get_dump_page(); and play nice, allowing __get_user_pages_locked() to drop > > the mmap_sem if it has to sleep. > > This makes my skin crawl. > > The only reason for this all is that page cache flushing. > > My gut feeling is that it should be done by get_user_pages() anyway, > since all the other users presumably want it to be coherent in the > cache. > > And in fact, looking at __get_user_pages(), it already does that > > if (pages) { > pages[i] = page; > flush_anon_page(vma, page, start); > flush_dcache_page(page); > ctx.page_mask = 0; > } > > and I think that the get_dump_page() logic is unnecessary to begin with. Ah! And even though flush_cache_page() is broader than flush_dcache_page(), that's actually unnecessary, right? Since the kernel only wants to read from the page, and therefore e.g. the icache is irrelevant? Yay! :) I did think this was a bit gnarly, and it's nice to know that this can be simplified. (And now I'm going to avert my eyes from the GUP code before I start thinking too hard about how much it sucks that FOLL_LONGTERM doesn't drop the mmap_sem across the access and how much I dislike the whole idea of FOLL_LONGTERM in general...)