From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B134E77184 for ; Thu, 19 Dec 2024 16:08:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D23526B0088; Thu, 19 Dec 2024 11:08:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CAC406B008C; Thu, 19 Dec 2024 11:08:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B25BA6B0093; Thu, 19 Dec 2024 11:08:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9445F6B0088 for ; Thu, 19 Dec 2024 11:08:24 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1BE31C0881 for ; Thu, 19 Dec 2024 16:08:24 +0000 (UTC) X-FDA: 82912189542.27.927B6D7 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by imf08.hostedemail.com (Postfix) with ESMTP id 1BE9E160007 for ; Thu, 19 Dec 2024 16:07:59 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kv1VnNSh; spf=pass (imf08.hostedemail.com: domain of surenb@google.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734624480; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YQEr6GSEtuEIr80AgS3GqbdNAQ58Tai2FwrUUBAgQXs=; b=kXV0sLVcNbELjj+VZ0f6G4mO1rULRoausZw+XLvJ+PpEf6umdGzpKVHUwP31CKikQlo2Xf 8ngOvvsQmjeUXysvwXL/dU9rid0wmkkuLvNtjjKRXduzy5EIEOINxFYCXSwKvhaWXHBizg MV30JgHdJtNcVwSXdiTnbdcW7nIO37k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734624480; a=rsa-sha256; cv=none; b=axHskV4qn/vZL9FI3N0Mmi6nq5lMWRcH8naaTCa2blnUHukNZzJgQdW10jY5yznNu8OsbT NCJvyMVWGKtegtBJxZp8T6nPBr4qkNZJF2mUWKNSWub0ZJfZZC/OdPUqkxRPx0IQ81ngMX imMLOqMpghBUAbeEvb54ArmlQ+mimZo= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kv1VnNSh; spf=pass (imf08.hostedemail.com: domain of surenb@google.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-467abce2ef9so317471cf.0 for ; Thu, 19 Dec 2024 08:08:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734624501; x=1735229301; darn=kvack.org; 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=YQEr6GSEtuEIr80AgS3GqbdNAQ58Tai2FwrUUBAgQXs=; b=kv1VnNShRulMjmRiuNQ3Mtp6cwp9t2kAoWBF7tHpDLjHIe/3s8m0NQaMUG9/qRrTmG MfmJhk+yHAEuI2wlPZpnpOh8GH+LXSAH9p28vmu+K4yBGgm8mCveVKjylWIoyyX+oI6n 3uGor2wwyKjBSJrn6v7SFy3Sui7pw5STy0D0Lz046EUneCden+2GYp/5uSHEJc5O3RUD Sb0iiz49A5Cb6LjmSxvl1c6w2ifqMUeMPxdWuhaIAfCz7KxsAEsDgoYo7+wp8rHyKDOJ PpPLsWFQDQc2XGFO0jWjfyWCk3b0N1IW9KeXtJVCfV5b2nB8bsZIP7z69BT8/0ixQKu2 I83w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734624501; x=1735229301; 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=YQEr6GSEtuEIr80AgS3GqbdNAQ58Tai2FwrUUBAgQXs=; b=dgyErJpGnRwA6jsCE+PtdxOdW4SbXQ3Nb3GhU84FFvW3MtkoMDGsLGfJ9DJGHjxM65 QGoyywHVF5S7m4VMgy+w3tbM5PEOdMCfYQ3IG5FHZhTJJ4AcLA9g3brVbqqFjSJeFTAW yfwLUKGb5QVhxXnq/YXjbGI0b/YWKtb51HnMHDTqAVOmuD9PjZMbPrTwhcd6nBp+l8pF 6cUUOOPl/dFtqep2NHeLxCu+2fHsFyScolbUbAPFbb1l19+BeEp8J9R53Cvhv0eu6oZl M5/iqAcXbR0LTLsXqZOulgPTzUH2jBRJQAKaIX14fSKDSEo+gbD7xX0KimSx2T2ey1LP EPtQ== X-Forwarded-Encrypted: i=1; AJvYcCUZMLwNZpgY+pAFsxyOQyVHuoOl5n3cioxJXnP/EUvBGAOi0GyU4/InDbkMXN/6K/L23/fznCkySg==@kvack.org X-Gm-Message-State: AOJu0YyZuXG8FVaK6CgpAKcCvMFEsf/KWkPFv1rn/T5qWojnU5uGUaLh 06RwWVr3wf3cERnttkSWil2GtL7erLIbVbOugiIulaBAokPzcvlL7rpavb1vS8RMhaNXxYhfTSf Y8KwOQnNNt/RlfVW+gGhQMk9BMIetV4Y6j7A5 X-Gm-Gg: ASbGncu8WLFO79CGj6aIrRlBJjsXI/Sr2c/G3qoZIPAUbzdduzP9SF6/6u0Ec8hEpmo vPPRm0IzMoC4qksYZPQmbYPdAQF+O1KOCyjGiCQ== X-Google-Smtp-Source: AGHT+IGwsQcyLlf1a93KTfVc5eZas6UKzid4em28ST7skzxkFy/tov3QwCf8dLyO0bw5a5+gaQtzzoEMgu99ZDqR8K4= X-Received: by 2002:a05:622a:7:b0:466:975f:b219 with SMTP id d75a77b69052e-46a3b979807mr4450551cf.8.1734624500958; Thu, 19 Dec 2024 08:08:20 -0800 (PST) MIME-Version: 1.0 References: <20241217103035.GD11133@noisy.programming.kicks-ass.net> <20241218094104.GC2354@noisy.programming.kicks-ass.net> <20241218100601.GI12500@noisy.programming.kicks-ass.net> <20241218161850.GG2354@noisy.programming.kicks-ass.net> <20241218174428.GQ2354@noisy.programming.kicks-ass.net> <20241219085311.GA26551@noisy.programming.kicks-ass.net> In-Reply-To: <20241219085311.GA26551@noisy.programming.kicks-ass.net> From: Suren Baghdasaryan Date: Thu, 19 Dec 2024 08:08:09 -0800 Message-ID: Subject: Re: [PATCH v6 10/16] mm: replace vm_lock and detached flag with a reference count To: Peter Zijlstra Cc: "Liam R. Howlett" , akpm@linux-foundation.org, willy@infradead.org, lorenzo.stoakes@oracle.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mjguzik@gmail.com, oliver.sang@intel.com, mgorman@techsingularity.net, david@redhat.com, peterx@redhat.com, oleg@redhat.com, dave@stgolabs.net, paulmck@kernel.org, brauner@kernel.org, dhowells@redhat.com, hdanton@sina.com, hughd@google.com, lokeshgidra@google.com, minchan@google.com, jannh@google.com, shakeel.butt@linux.dev, souravpanda@google.com, pasha.tatashin@soleen.com, klarasmodin@gmail.com, corbet@lwn.net, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1BE9E160007 X-St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ks8PRI7UKq9QkzadWAvOaQu+l5NCdEvysQP6DsuXhNW4VHk/iPoGf6Z5FjxRqJSwf5jhOaFJegh+BnUBa4ujMLImgxm7WwOTBUIQb05J5xpsNfbpOukr2ju4R75b8HlQU2fiIoD5brRmLlDebbtU1gbvMJhUx7lUi/diCihNDn8GRfT//OxSYvmbCUgoa2PlZC9c+sgI/UUOJrGCHc3DGKbS2545MB1E8s7gu2gHqqPUMiqIZFm+8xUpD/RO0+/iImJHaMbd1Sz6BknmWRIYm2+BvCuPLc4cr/bsMIoqjaE0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.086020, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Dec 19, 2024 at 12:53=E2=80=AFAM Peter Zijlstra wrote: > > On Wed, Dec 18, 2024 at 09:58:12AM -0800, Suren Baghdasaryan wrote: > > > And remove_vma will be just freeing the vmas. Is that correct? > > Yep. > > > I'm a bit confused because the original thinking was that > > vma_mark_detached() would drop the last refcnt and if it's 0 we would > > free the vma right there. If that's still what we want to do then I > > think the above sequence should look like this: > > Right; sorry about that. So my initial objection to that extra sync was > based on the reasons presented -- but having had to look at the unmap > path again (my mm-foo is somewhat rusty, I've not done much the past few > years) I realized that keeping a VMA alive beyond unmapping PTEs is just > plain daft. > > So yes, back to your original semantics, but cleaned up to not need that > extra sync point -- instead relying on the natural placement of > vma_start_write() after unhooking from the mm. And not for reasons of > the race, but for reasons of integrity -- VMA without PTEs is asking for > more trouble. Ack. Thanks for clarification!