Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1798460rwb; Fri, 28 Jul 2023 15:27:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgviS5YDQKaql+p4slW8/VFr8tfzJqVx//hoIvsMykPfvuW1+mkGanNj2t5sXB1fMBC4wo X-Received: by 2002:a17:903:32d1:b0:1bb:d59d:8c57 with SMTP id i17-20020a17090332d100b001bbd59d8c57mr2920894plr.18.1690583278523; Fri, 28 Jul 2023 15:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690583278; cv=none; d=google.com; s=arc-20160816; b=CWGuPDFmBaShpZyoggFbThLMA5vRkjnq8PL/oYwGiA1kgnfqLD9yKKFSW7QIgnp2HH o2V0mhJgD7/E/YnPVTqtvHbhOJnLnGKLATGEe0eLUI3dn0hCCzcQxCv9nnDCCQFHjCJr a53HajEqh6bk4TifLV29Xoy8+/W9ISTFYMZQ0XjUxNcSHQqfWpqSedgZ1KKHWbSuaM6Q m3fj3qxTGcDLx/TkwloAyozXzuO5MnTXaP39O8dWFhV897WjbYmLUv3ifzLm3Db+lD3X lb8EFF0QiU8HBWiABNHolAOVr2B+E1L1K291xrhwGC99uoMnouE3gcem40EOuURYsuac 2WUw== 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=DaL8vCWD2qZnjDMvOO1mSqawEYt68vZaybEyeqD8qzc=; fh=EX3MXeeaOGtKlgGQziVU5J7ElO51tDbVAJdUb6En/HM=; b=B9MYBbXIGbNlG0Ev/vFFOP1x6QCstUEYlDngEjPkSdtxYfl9Z40lND0mcwsd21PJuw 0rCMf2mhKVu1HzZxlrTvNmbRktBFwgx5h0rNbcyHfIUkq854NWPhGFkBbt2/YdfUPsWF iYnkR2LW4y2ILlOuP29KghStu/DuGH5RRD/c7HYa18fY90UlNsbcf2y7Ir4KbIaKJOnT I0VgT3BHBFa3nYPKCukqzFo7ZkAJx4VSVbgwFHqxLAyU4LaTBIxcqjHKuUPYswQBgx0/ +ISa8azrDpQrxft4r0NNL6miA18z0p1vkv0xQY4UYvQQKlnSRmWj0XKzHLEaiKXRNGjw J8fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=iNa4V4wb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y12-20020a1709029b8c00b001b8a591d5b9si514079plp.133.2023.07.28.15.27.44; Fri, 28 Jul 2023 15:27:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=iNa4V4wb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231713AbjG1UXe (ORCPT + 99 others); Fri, 28 Jul 2023 16:23:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbjG1UXc (ORCPT ); Fri, 28 Jul 2023 16:23:32 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACCAD4483 for ; Fri, 28 Jul 2023 13:23:31 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-52222562f1eso3310530a12.3 for ; Fri, 28 Jul 2023 13:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1690575810; x=1691180610; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=DaL8vCWD2qZnjDMvOO1mSqawEYt68vZaybEyeqD8qzc=; b=iNa4V4wbqIB8YQAIu3YWecMdqgfDDBvx7YotKRvzxFMEkV1NPN9FFaahGfVAarwaAV kRJWDO6+avyfDWom2I0N3AENnd/ucA3n3b4Lmo9UgnRCWibEYgsywdeA1ZqkQqRmTlZh XV8dRItJxUnXX6LhTgM/AywiqSgw2XGInhu/8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690575810; x=1691180610; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DaL8vCWD2qZnjDMvOO1mSqawEYt68vZaybEyeqD8qzc=; b=kIVOX4YYLFp/9cTcfYi/XiRwMDUa4XEAPyfHcdpd+R89rboXsEBIVENHRmWq1xROrh 8/v2z8sbz4zy7f3EEFDeTXXnaaDWrROJcCnjWy0dqE9GGMWd0iWKMPOqXushHBCT8WO9 fdKb+QY6sNS29jmZb3Rqd9U0dyO2AlGhenOQiCchN3pUNqg/KDcHwCszp+I2KMsZ50Bq v87CsKG1DFdysOVIq+3RgB5iLYv2N7IwaKoCv/RxjvL5QW17Bv4+mvWdgdSM3dzYKOiJ LY25dv5kFtKtHuf1+UoO0aMTMZPGVpllwUp4TBHzrlnpY8Ng9LY1y34KC+4+Fg1Y1nZW 7kCA== X-Gm-Message-State: ABy/qLZgkh2vnGvDQpJRYxtruVZ4UfUhxspFwIKsYx52GrMNCi7NUfyi F/X72WJZF8upqMFrGJw42/O8fhSmHXglvO8Mg/Bt0qez X-Received: by 2002:a05:6402:756:b0:522:561f:83c2 with SMTP id p22-20020a056402075600b00522561f83c2mr2513883edy.1.1690575809909; Fri, 28 Jul 2023 13:23:29 -0700 (PDT) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com. [209.85.208.47]) by smtp.gmail.com with ESMTPSA id d7-20020a056402078700b005221ce96801sm2181181edy.35.2023.07.28.13.23.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jul 2023 13:23:29 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-52222562f1eso3310502a12.3 for ; Fri, 28 Jul 2023 13:23:28 -0700 (PDT) X-Received: by 2002:aa7:d507:0:b0:522:3a28:feca with SMTP id y7-20020aa7d507000000b005223a28fecamr2820293edq.24.1690575808575; Fri, 28 Jul 2023 13:23:28 -0700 (PDT) MIME-Version: 1.0 References: <20230727212845.135673-1-david@redhat.com> In-Reply-To: From: Linus Torvalds Date: Fri, 28 Jul 2023 13:23:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 0/4] smaps / mm/gup: fix gup_can_follow_protnone fallout To: Peter Xu Cc: David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Andrew Morton , liubo , Matthew Wilcox , Hugh Dickins , Jason Gunthorpe , John Hubbard Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Jul 2023 at 12:39, Peter Xu wrote: > > But then does it means that any gup-only user will have numa balancing > completely disabled? Why would we ever care about a GUP-only user? Who knows where the actual access is coming from? It might be some device that is on a different node entirely. And even if the access is local from the CPU, it (a) might have happened after we moved somewhere else (b) who cares about the extra possible NUMA overhead when we just wasted *thousands* of cycles on GUP? So NUMA balancing really doesn't seem to make sense for GUP anyway as far as I can see. Now, the other side of the same thing is that (a) NUMA faulting should be fairly rare and (b) once you do GUP, who cares anyway, so you can also argue that "once you do GUP you might as well NUMA-fault, because performance simply isn't an issue". But I really think the real argument is "once you do GUP, numa faulting is just crazy". I think what happened is - the GUP code couldn't tell NUMA and actual PROTNONE apart - so the GUP code would punch through PROTNONE even when it shouldn't - so people added FOLL_NUMA to say "I don't want you to punch through, I want the NUMA fault" - but then FOLL_FORCE ends up meaning that you actually *do* want to punch through - regardless of NUMA or not - and now the two got tied together, and we end up with nonsensical garbage like if (!(gup_flags & FOLL_FORCE)) gup_flags |= FOLL_NUMA; to say "oh, actually, to avoid punching through when we shouldn't, we should NUMA fault". so we ended up with that case where even if YOU DIDN'T CARE AT ALL, you got FOLL_NUMA just so that you wouldn't punch through. And now we're in the situation that we've confused FOLL_FORCE and FOLL_NUMA, even though they have absolutely *nothing* to do with each other, except for a random implementation detail about punching through incorrectly that isn't even relevant any more. I really think FOLL_NUMA should just go away. And that FOLL_FORCE replacement for it is just wrong. If you *don't* do something without FOLL_FORCE, you damn well shouldn't do it just because FOLL_FORCE is set. The *only* semantic meaning FOLL_FORCE should have is that it overrides the vma protections for debuggers (in a very limited manner). It should *not* affect any NUMA faulting logic in any way, shape, or form. Linus