From patchwork Sat Jan 11 04:25:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13935771 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 1E367E7719D for ; Sat, 11 Jan 2025 04:26:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 763D76B0093; Fri, 10 Jan 2025 23:26:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ECEF6B0096; Fri, 10 Jan 2025 23:26:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F1C96B0098; Fri, 10 Jan 2025 23:26:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2A6576B0093 for ; Fri, 10 Jan 2025 23:26:22 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 905361C697F for ; Sat, 11 Jan 2025 04:26:21 +0000 (UTC) X-FDA: 82993884162.28.D81A6E4 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf20.hostedemail.com (Postfix) with ESMTP id D099F1C0007 for ; Sat, 11 Jan 2025 04:26:19 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lGHJPSek; spf=pass (imf20.hostedemail.com: domain of 36vKBZwYKCBsJLI5E27FF7C5.3FDC9ELO-DDBM13B.FI7@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=36vKBZwYKCBsJLI5E27FF7C5.3FDC9ELO-DDBM13B.FI7@flex--surenb.bounces.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=1736569579; 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=DOG/H7ntoUGENirNHb9FT3KOSm+fCVqVeSZvHaxSDJc7xa2tMZqDqF/dMytIISF3afMC+T 4oP3jummRTALlKH1oYrG1sq+RFITTZwR43EH3U/uwrs1GUU7RXV+qASjvUuDB1/YKwY/QN B28AtxwNkJPI6fmLWDT+q8JyB+0n4Sk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736569579; a=rsa-sha256; cv=none; b=Lbq7ak2Vcv0X23LjqRNmNitWvkgvJ0hvuKoL5e4ysdEV0GoVYH+HROR6gMIh5q0g+3e66G AQ2dPwE9yCP8AwmMxT8bVhe8JN7hA72vXz1rRSR5WH9/tQngk9cv5PkXj6kvCcRYNDIp4K r2aiE44Ov2el+ouuC34bUIy+Js98Ma4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lGHJPSek; spf=pass (imf20.hostedemail.com: domain of 36vKBZwYKCBsJLI5E27FF7C5.3FDC9ELO-DDBM13B.FI7@flex--surenb.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=36vKBZwYKCBsJLI5E27FF7C5.3FDC9ELO-DDBM13B.FI7@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2161d5b3eb5so47488235ad.3 for ; Fri, 10 Jan 2025 20:26:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736569579; x=1737174379; 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=lGHJPSekaEgY+xsifnv9HeI24Odq1LZE4S+2gYYeWG5LBgoJzgn8xEr5QVF3qT1nLC 6y8zAXBBeMneIgaNt94LsARWQlydtMu3TkrOzZXTJy6aDE/zD4Z9Aay6QTEvo+Qj2xfe JdqUNE6ur5gLWzhvMXdIwaEKbj541B4tQA+LUJoYDccEuadZ2AFShuKixATVvvmqj7Wt /Brljhd9baiCSakvAw3U5kXBmLQ4ikThUfiGV3Sp37a8ahVEJ1arm+IsUCOl0ZVWgXIN cRRgh//QOfMm8crdxOO90eV++Slzf40i+CROFDwLJLEeVbhss8GusaLFuo4yfVuoZxOQ 9WsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736569579; x=1737174379; 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=b5ztiZUlscPjBSpXFIyCOF3haVyp6cfUiCFumdaSfO1Eq7lALp0BH9wVvGyRbYkk8v OGfgcDZkglB/NJ5akh0H/6BLLeGDLamyS294oE+FQCJBVuE5gWXrtRnSu1cAKwPOvJPD JZZXV+E0QxyIT1xA5xuwRxyzGVWmd7fuIBxfs/aglOlLv+dY5ylIwm5vs53l9Q6oEDRv dI/V+3GhHWzV/9gf3eJE8ZZOGFkxlSVehX0qeAlje/xxFmedbYDdu65fFotZdZsYFb93 xraV06haS+3Wt6k/+PhnrMjqXwtVsAJsXjAJI5b6EtT+I2sx0ghOuvzb+6B9BKYloc5o I5SQ== X-Forwarded-Encrypted: i=1; AJvYcCUYaxyjpGB80OJNbexmki0JZUYWhAIn4JFOWievGitKBwcumVCRmVdhX0U5gpOCvUNZ++8m4LKalg==@kvack.org X-Gm-Message-State: AOJu0Yzt+bhWNlnkmrthqbm7IGh706okzkeejHfiD8LLZcMzXzOBmNU2 e0pkW2V6jnDZWnVFG64ioTzAtkarDnB311ZiZquzbiQeOcimQX9ZaV0vlY4pyVqSEZOr+OSw8Y8 vZQ== X-Google-Smtp-Source: AGHT+IHnRj/SaQAEPl0ebQpZxgzIjgJT++Eb5qi3sriuXSku4L0jGeJRI8Hfnaea64zScjmdjPJijWAPl6E= X-Received: from plsd17.prod.google.com ([2002:a17:902:b711:b0:211:f320:a598]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f64f:b0:215:5240:bb3d with SMTP id d9443c01a7336-21a83fe4915mr197586285ad.42.1736569578687; Fri, 10 Jan 2025 20:26:18 -0800 (PST) Date: Fri, 10 Jan 2025 20:25:52 -0800 In-Reply-To: <20250111042604.3230628-1-surenb@google.com> Mime-Version: 1.0 References: <20250111042604.3230628-1-surenb@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250111042604.3230628-6-surenb@google.com> Subject: [PATCH v9 05/17] 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, david.laight.linux@gmail.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-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D099F1C0007 X-Stat-Signature: 8prucasig9zz17535yjku7gfcgf5guuh X-Rspam-User: X-HE-Tag: 1736569579-643887 X-HE-Meta: U2FsdGVkX1+jbfYPgjjb4NzChgaKv1z1K2YFI3q4wOr0GHt5qn9ZmyoSSbKmDIY5OsNiXsSpoZUKk95VYaa1j0F7w+zYds2XqvzuUbMBncCwXXbOdW+e20ynEwYpeiibre5JGpubc5PqbHCoIDf1iuphY878QWYhTp1wdZEQE+2/aGjhUGZRmmUr1gbqPtkq/7ga0m6mAZ8V6VMrHCohVVUFB1BQuaJeJY7Ta7N6LnAY0by1Y46RtMzoBjfycEn2T98VOQbT8kyof4C208yqGWkzahEXUK+RDi7K9uxKsJgH9kA2hL76kbopc/HZO1C4EwybXlRGThTXythgqvwHIs8ow4HzYLNsSiCNAFIcaW/4djM/ZP8APp1BRHaXzlQGqCpH1zQAcIFSDmgZrfRptli7dGX+pKq+6PrgyGrYjcOfhrE0Ad/uUInIcKr/pe8OcliLnj1da5MEbLF4gqiEIf6YgIsAOMKSxKhIe6is7B90Kh0Gs1GoiaDN2WPOIux/nQI/KcFNJ6ELRGOO/L0FFHUzODJDCg4d9X/Zjvozp9vUxyur5gqDH7tKDds8yIhr+daZ9NB3bCy5WDRcCUbF4Az5S8mptG6+ly4zFhvOrtWGsYTmWp+6EcGfregE2DJqrCzTczPKjSM5ntsk780kuQWBjPYLqIEU8nJuKW6QoSrrgBYTIj4sQ3B/FQ2cbuc0WyRDvDu1SwQXXJr3waBYRNHAuCq9QnDKDtZLpkzgYuwXyHmOUv/Fcb8fGyvv/b30owu2GvABFfmitevuZ7z8LjAhjs15AVu0ov18p9vAARSV2vw43JTYYCgDF4JXVIej025utfp/oXwFMY4tBYeRxOgtOBoOXZtF6wKpOObSK4+rdTkLaNrgOcyzFuC2xmnligI3DTcFcVDCd2vpign3rxyWnZmLnfowVxLQa8Bft8kBTuIuMuWpD0ggZSldgybM1w/V53IYw0di/ZzqlUb TZiDXnyc FeiWbtq9v4Bqy8h4Ly64dM0GYwS5KV1Su/Ooj0VoRuWYaoZ+8afvzlmURYxKvti1itLv39gx4FNTKrygfYvr/QjpTtLHJhvC50gS1YXfITcHGtZuqTk8vwS78KTcTx4LGWGwrJPv26IG6jhlaNP3VlgpSfJahrXyLl98Xo5vVeDc1RP23gNn7t45NnxUE73u+Vr/1XWAFS6l+rJkxOv8UXkIr6p3VZuJmkcujcuKYZJpTesE1mZyi4D0Gdem5Su+LyRnsnYQeLQfalNZzHh8C2gjFzZcENI7L/ehHf3m/TymInSMuXc5ajx15oJ/18oyuIwY3+kResfCVRq5OHELyGDT7hD3Zesn9NEJxBHF4+EGi9YaZ/ayFw/22lJ0up9ZVa2AptHepsl7BHmtrwl+6aWrmK/bGII5vVQRME2Ba1z2Nxd5he+47VjErq/6R2G6nB9/b0TuMkVv2jiLqQ1BpP9ZkOZf6GjTirywSKSROUaBGJGOiT+lD+Z/eVgtt4gu58SV5jeYa1FfRnr1e3rJK8GJ69V3ZNxKwohWE9FgMtaA3yyH4OKFxxuFjE4sz5IHA1iSOmU6vNsrRQWzrwhRRJF9OuNuYg7/kl7FXRp2XGnwV9JE= 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); + } } /*