Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10904007rwr; Fri, 12 May 2023 15:06:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6htMrlpxEI5y6IXbHABOI6QfP/KJ2IwU0D5x06L37kRVQLW0qsrHunggc66FfwMzN035Lt X-Received: by 2002:a17:902:c412:b0:1ab:25a6:a54b with SMTP id k18-20020a170902c41200b001ab25a6a54bmr34905110plk.4.1683929170330; Fri, 12 May 2023 15:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683929170; cv=none; d=google.com; s=arc-20160816; b=dsvRmWwXl5cIFs/e4HieB1kbteZPSLuFgZdZ1tVKYK92bObpuwQgVK+xQr/MJ80x8+ pPj88E/7lAttAGOaQvwFTD/m5jNOdpfzDS85R6s52U5FOjYnueWHBysQ40REPEZm80Hi 6OXuwJokk5xdqMdENJ4Z9OcSHNbAhWfKDIwTyEW6Aithhlw2NpIaXXTeR8zWwujfjvAo Gfx2vpJzk6lFtZyzCgeYPXeDfCB12HrjtsvWd7oyLkoc+bSxYJTWyAjp/tF1Th2IRAm0 Lxnv7Jbbt58/3bCm0dOaFVpj5wyhjYhK5Ee2szkE/zB5SEI7lmWi3b8deWHYsCX2e0C7 aBXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6fiE+4tw4ReS6W3aCfl6G3CwoVaQuhNT/4YECYUltEI=; b=t1cQTR7WIIwITfzybmc8C1gshpAKQjojXkiyzgt+mjbHOsf46TfQBZzt3U8+YsIVij ljz6j07vaAM0k/eOjG/r8RoNrcwq9nhQhiYLErRxITy877ut+VlPDHcXzdqczokUdYyx wGmB/a6iB8L4PMrxvYwQXIwHCA9fAMSorFvcwkyZP7dNpy51n6TEA9VzaH58SX09ReHm 0E4rENXrtq3QvB1DSVEQ6loDoX6fv641I+MOa1SwW0jwOWEtMpTKA6+z1CEvVcyP/3Ep BPL7bFd/TKktBR4IYEfl48/zrM65DWXEY+FTOVfG4ozswloJHAWnuDrbLjk9bc4cIOBl LOoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="OJJr4mO/"; 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 f15-20020a170902ce8f00b001ab10e58308si10881119plg.400.2023.05.12.15.05.55; Fri, 12 May 2023 15:06:10 -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="OJJr4mO/"; 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 S238974AbjELVzZ (ORCPT + 99 others); Fri, 12 May 2023 17:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbjELVzY (ORCPT ); Fri, 12 May 2023 17:55:24 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7643B7A80 for ; Fri, 12 May 2023 14:55:23 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-50bd37ca954so93443526a12.0 for ; Fri, 12 May 2023 14:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1683928522; x=1686520522; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6fiE+4tw4ReS6W3aCfl6G3CwoVaQuhNT/4YECYUltEI=; b=OJJr4mO/dcfgE5zhlhhUEXfXNxlmuDngURq/m3HsbWoNM4ajZzUBnlwX2VvgFqtSg2 rkmDSQ4Se2maurYnI4ymDN541x414zXYSiQuObhmxHDN889MsAD6KGgilyeaeWsyu1ql cGjhL5ZIsnvuMiaEn91Xo/0ffWdPrBLHGzOV0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683928522; x=1686520522; h=content-transfer-encoding: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=6fiE+4tw4ReS6W3aCfl6G3CwoVaQuhNT/4YECYUltEI=; b=l9f48Dwj1faWTvRg+4X7hhnTbS0HkcOD8/amUKlVfJkKfe7yZR7izx56e7V9vS262i YfXAtJDl2I9vpGLJCWRTGAMfIhyUtVUXHWtomLlbx5AzYFYWfw+meNUw9ibldtqswmkI WXQOso7QMXQ/xk1FKCC3hjtSh6j5F7+qPVrkQGhl3N17eIpOrWcuuCuEMdJ3OBElVYFy QPPPDqm0lROZurNFZ898h/uE5e0K87OLN18YGMxvNTidk9zoJymG+I2XbCvTI1Qz1fQO takw60eWmfJxz3CAGezsi+00IcH+TqtAGzEpATTA4ULA8QFoTBMuvMtIQ0NaeUo/1GWm t5Ig== X-Gm-Message-State: AC+VfDx7LhFnCreP6n2ZmhrFcq8dvdOY7rll1tkpoj/wgYVZToacY8zv LtmQpcjliUQ5y9lLG6P2tOJs6tWZz6yj6S/lFlo= X-Received: by 2002:a17:907:9306:b0:932:f88c:c2ff with SMTP id bu6-20020a170907930600b00932f88cc2ffmr23046719ejc.34.1683928521765; Fri, 12 May 2023 14:55:21 -0700 (PDT) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com. [209.85.208.41]) by smtp.gmail.com with ESMTPSA id og16-20020a1709071dd000b0096637a19dcasm5944901ejc.4.2023.05.12.14.55.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 May 2023 14:55:21 -0700 (PDT) Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-50bd37ca954so93443389a12.0 for ; Fri, 12 May 2023 14:55:20 -0700 (PDT) X-Received: by 2002:a17:907:9306:b0:932:f88c:c2ff with SMTP id bu6-20020a170907930600b00932f88cc2ffmr23046686ejc.34.1683928520392; Fri, 12 May 2023 14:55:20 -0700 (PDT) MIME-Version: 1.0 References: <20230424212130.590684-1-dave.hansen@linux.intel.com> <4433c3595db23f7c779b69b222958151b69ddd70.camel@intel.com> <148b3edb-b056-11a0-1684-6273a4a2d39a@intel.com> <4171c4b0-e24b-a7e2-9928-030cc14f1d8d@intel.com> <95c2e669-bce9-3dd5-e197-3faf816c4b45@intel.com> In-Reply-To: <95c2e669-bce9-3dd5-e197-3faf816c4b45@intel.com> From: Linus Torvalds Date: Fri, 12 May 2023 16:55:03 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] x86/shstk for 6.4 To: Dave Hansen Cc: "Edgecombe, Rick P" , "dave.hansen@linux.intel.com" , "keescook@chromium.org" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "akpm@linux-foundation.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, May 12, 2023 at 12:34=E2=80=AFPM Dave Hansen wrote: > > Were you really thinking of mm->count=3D=3D1, or did you mean > mm->mm_users=3D=3D1? Yeah, I meant mm_users. And I was thinking that if it is 1, then it is stable - kind of like how we do our optimization with file descriptors. But you're right to worry about possibly other users incrementing the mm_users count somehow - or just using "mmgrab()" to not increment it, but be able to still fault on it etc. > There's always a race there because mm->mm_users can always get bumped > after the fork()er checks it. Ugh. I was assuming that if they don't already have a reference to the mm, they can't get one (becasue the '1' comes from 'current->mm', and nobody else has that mm). But maybe that's just not true. Looking around, we have things like pages->source_mm =3D current->mm; mmgrab(pages->source_mm); that creates a ref to the mm with a grab, and then later it gets used. So maybe the "no races can happen" is limited to *both* mm_users and mm_count being 1. What would increment it in that case, when 'current' is obviously busy forking? That "both are one" might still be the common case for fork(). Hmm? Linus