From patchwork Thu Jan 9 02:30:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13931812 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 54CE1E77199 for ; Thu, 9 Jan 2025 02:30:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C9036B0099; Wed, 8 Jan 2025 21:30:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 952096B009A; Wed, 8 Jan 2025 21:30:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70B5E6B009B; Wed, 8 Jan 2025 21:30:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 49DFB6B0099 for ; Wed, 8 Jan 2025 21:30:43 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B7F38C15E8 for ; Thu, 9 Jan 2025 02:30:42 +0000 (UTC) X-FDA: 82986335124.23.BA27F5B Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf21.hostedemail.com (Postfix) with ESMTP id E94961C0009 for ; Thu, 9 Jan 2025 02:30:40 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="LsbDi/aY"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of 3zzR_ZwYKCHgoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3zzR_ZwYKCHgoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736389841; a=rsa-sha256; cv=none; b=IM85Jt2htlDoUmV9D/d5DkfGGMg/APO8vQlFMKAj7oCjdkqONkPI+YZYdpyJlWi2rtqEU2 TINNtY4DIuYXxcV7X36zjI+f5G8w71ulaSU9zlaK75ovuTR3gk0I8nrcYYEnL45+9uA0ht 6zTWJICD5W2c6y/7wi1eOSXRFBEKuCc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="LsbDi/aY"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of 3zzR_ZwYKCHgoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3zzR_ZwYKCHgoqnajXckkcha.Ykihejqt-iigrWYg.knc@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736389841; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QrBwNMjEBhpbcxWqFk88nlV6Pfhf+HDin7YMebARszw=; b=PZiIZ0P0rEOpN2O6A/pUbUn4u+ZoPIy73pVSqYPXN4tjYSgkiCATCYinvj+yeMWdEAQfPc XDSCI2g6kWiDWAsxioZRTD57t39I6YW2Pwmeb55EZEF9FsEvXHCs77hQEQZrtywYhWd7E4 L90r26m6rhtBUp8y9FsG/sL8TMtWiFI= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-216405eea1fso6759945ad.0 for ; Wed, 08 Jan 2025 18:30:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736389840; x=1736994640; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QrBwNMjEBhpbcxWqFk88nlV6Pfhf+HDin7YMebARszw=; b=LsbDi/aYjxWHxQQnY3QFFjC7s713L8kti6YJE/5wq/1+dcWM9RG1fFRjyGk6UhRFSG rmNDK+nZlSi028nix2VYmQTaRUQO/L3IX8suKVrpJGSKPzYLK9DBQFqvUE0hlG0cpDaj cXTJdvgLrCNOcY+9MIv2+8yYVElnwaJQ7yNDDHfrGwHQ7hoqo78sJAbRrxL5eqIo8Hpz /B7d1qidRd7nfOay6A2x1LTOhyIN2LtFBeSRtoZ1fZQYKXo9rCiPedBzU4+jqZBm8Z0b BBS+K4PQ/PLoYMEHQpwj3BSGsiMDpwyAc+r440MbbDNhOpAy6CDevkMlMcuiqRH2Szoq 7JAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736389840; x=1736994640; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QrBwNMjEBhpbcxWqFk88nlV6Pfhf+HDin7YMebARszw=; b=JRdG/mgrWHDcnvZS7fR2S3mm5JkR+4YmnIdVJXWNcAtm4OLvVA59qnwDpXy9nCcklY x2tQdBvYb4YoEsTNwHLtRe1dCnPw9vNYgyj9FXhnjkpxfLyWVQFaE9GlQXt2adsiiK0e cNNS2qXMkOIvSPJ65k9YOKl43XM1CkJUSRnTfE53QvBez1ajPox+6wC9aNFScdJDXzEq D3LP4aBYNmUEZYjkKA5YjagmiNfwS3mFpXR5J9ezlCuNYMgWLEOE3RwzvlIbzjNRfQLT zARXPBD8wh2y8G6BhyCzgqUqUjM0zuDey4U7BiL+F1ehc+rk760Ghb4oGyLbFvee+XIe kTzw== X-Forwarded-Encrypted: i=1; AJvYcCXUZXkadlAjxPoRv99LhugLZfz8kmIO5fnQwPDxZGBjlggRsdFktPpVFa3ufT7QR1KiDttDrQ76Nw==@kvack.org X-Gm-Message-State: AOJu0Ywka9AbnheSACZI0YR3Yr10zVKt7+eMGF6MhewzoheTSmuJ02Za lSrLowfSCYz0vrFb8UgXGzuZ/CeUv9LvbTgHYLJCiZ0f1NIGin5df14MqF8Lbb9BR1KTvFJfCEk oWQ== X-Google-Smtp-Source: AGHT+IGCSi1cLKzQVkSU7lkundl6oeEMCOCXsG4KvMhn7UcrmY2u1vKpnTKufMOdZ0o1PI8HbdJQwt6UXwo= X-Received: from pfbds11.prod.google.com ([2002:a05:6a00:4acb:b0:725:e39e:1055]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:8403:b0:1db:ffb9:f359 with SMTP id adf61e73a8af0-1e88d128ee1mr9121257637.24.1736389839663; Wed, 08 Jan 2025 18:30:39 -0800 (PST) Date: Wed, 8 Jan 2025 18:30:14 -0800 In-Reply-To: <20250109023025.2242447-1-surenb@google.com> Mime-Version: 1.0 References: <20250109023025.2242447-1-surenb@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250109023025.2242447-6-surenb@google.com> Subject: [PATCH v8 05/16] mm: mark vmas detached upon exit From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: peterz@infradead.org, willy@infradead.org, liam.howlett@oracle.com, 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, richard.weiyang@gmail.com, corbet@lwn.net, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com X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PLW5UoRxJZTELrK4tSGr RLmXK8nd rlI1k4u92EEyIwo/NlN5s5OeIgrWyRX4XTAtnwBHbKsivae4VOCe0mS8KLETzyzkALWAgMeK1HR3n8e3706n8BTg9vYtFHAIoH246nuG6tj+kQJGMRzJE2DS9oF0wyLf77m1YBSnNa9SXFrw1vOEblvlQvEl2JeHtKuMJgJleAkWzx+JLc4tDYiIMt3kXUwWKH0yqIPcuMGNiirCQZO1u7OTkM1K6qqHI/m8ti8J68wd40eqP+hsTJOmAOq3/MK/nn2Jn5tjJLYIkUFuG3CTH/yWtZRM/cg7R7wa8vfB+MtCnc9/4btP8SsZLip0bsNarSaF397qgTqqBjXA2+pEXwGP7ki+yQln6+zfNb9BdUxfOwSkDRJiFu0iRu1gwzE/tcirbC7dqt26Z64wZxOM6yokJp8dBlGKMDeuL+ahTScJbqUrjFjRBP/F1XA2LH7FYsCMBCr/sUwN6w3yU5+4dB9Hj5/m958KOWO30123SMsp8m85BfumWvudUFe7DjbLidw4+s1CCY+8ZCbIpY6l+9dnuiktO0tbEy0nL2NoKqdwbSb99ybz+onJWUFfmZdzlxEV6G4h79kZZSLT6R8XQyB4DfE4KUH/eFuXs+RwYpri72lw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When exit_mmap() removes vmas belonging to an exiting task, it does not mark them as detached since they can't be reached by other tasks and they will be freed shortly. Once we introduce vma reuse, all vmas will have to be in detached state before they are freed to ensure vma when reused is in a consistent state. Add missing vma_mark_detached() before freeing the vma. Signed-off-by: Suren Baghdasaryan Reviewed-by: Vlastimil Babka --- mm/vma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index b9cf552e120c..93ff42ac2002 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -413,10 +413,12 @@ void remove_vma(struct vm_area_struct *vma, bool unreachable) if (vma->vm_file) fput(vma->vm_file); mpol_put(vma_policy(vma)); - if (unreachable) + if (unreachable) { + vma_mark_detached(vma); __vm_area_free(vma); - else + } else { vm_area_free(vma); + } } /*