From patchwork Sun Sep 26 16:12:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 12518935 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D763C433EF for ; Sun, 26 Sep 2021 23:43:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 018CC6113D for ; Sun, 26 Sep 2021 23:43:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 018CC6113D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2A18D6B0073; Sun, 26 Sep 2021 19:43:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 251176B0074; Sun, 26 Sep 2021 19:43:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CADD900002; Sun, 26 Sep 2021 19:43:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id EB0986B0073 for ; Sun, 26 Sep 2021 19:43:55 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 55A0430171 for ; Sun, 26 Sep 2021 23:43:55 +0000 (UTC) X-FDA: 78631354830.40.85E1B77 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf28.hostedemail.com (Postfix) with ESMTP id 12EDF900009E for ; Sun, 26 Sep 2021 23:43:54 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id d13-20020a17090ad3cd00b0019e746f7bd4so8739037pjw.0 for ; Sun, 26 Sep 2021 16:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5CQKKv99L0xnu1rz1XhkT9JsaYC+t+sel+8jyZ49o3Y=; b=gtU0EfnRnqFNYBWtEUGER6RW4YhSo3Ezaj9dW8XhWZny48xAihOdkmFf7LAENN4UfW 7ImzRXyt2DH6wK/1WRChceT3rCiQuFnonXwVX9ZCS4xsb57DsHqhQPmxDmgCZ8bLO73L KLTdKddD810O9bHzXYFw8QCiJaQNLkHSHU+4q2vXOOS53rWnx5VZ+K8TVvqTHxp+0nDj 115b41uAE4cRu+c+rOUSg5DC6CNCWcDkfhtCyaIO/fSqrTJKLLE/dN2fClZ1lu2Ty8CU LIObWi3YYcPgggDrXEmOT6EPndIRqf4UKAu/yQlbScERv+tYBndI2B8bfn7vcjiQ2xQV o+ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5CQKKv99L0xnu1rz1XhkT9JsaYC+t+sel+8jyZ49o3Y=; b=1TVqY3+jOBoCA3VK1xnlNtbP4hmFDmGDvIlHoICjB4Uf0n9vJlB/HDYqbeKHdKtkIe cUwJCkI8fwYqShs+Z3y6oivh4iitzODmUwvqpKrRRvSh5CMXWUN8mQTTo5lXc2kdtsxI YPqEqhNXqO6t1tQObxn7XGD74kdrKZJmBd2CyPusfFmKifmtfjFynPs2qItDm3+dKDR4 XIKfGvfctobmlp3xRw9kNi1R8mZXRVVn0M031vPeID0cbiScCQVJZmzdG0QUi4dQUVTF fsFT8iX0ExXjbkNtFrxMiwEmj/pmno4hgRAul87o0KpNkhZo5oq2bOVrFLvaTQcq836A YPKg== X-Gm-Message-State: AOAM530lF/jroflkK8Dh/yX5QJQr5N7Wl9JY0f9Hrj8MZpbQkqpCi2Eh 2JYlunUtJd2Os/5TOoMelPE= X-Google-Smtp-Source: ABdhPJzZXNgpk0RZkng+CNnHW3yPY3D9aVfvkzEamV6c/9RvZ3dkXeX2FGMFCRvzBnaGffL5wkf8cA== X-Received: by 2002:a17:90b:3447:: with SMTP id lj7mr16131508pjb.112.1632699833922; Sun, 26 Sep 2021 16:43:53 -0700 (PDT) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id n22sm16783686pgc.55.2021.09.26.16.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 16:43:53 -0700 (PDT) From: Nadav Amit X-Google-Original-From: Nadav Amit To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peter Xu , Nadav Amit , Andrea Arcangeli , Minchan Kim , Colin Cross , Suren Baghdasarya , Mike Rapoport Subject: [RFC PATCH 0/8] mm/madvise: support process_madvise(MADV_DONTNEED) Date: Sun, 26 Sep 2021 09:12:51 -0700 Message-Id: <20210926161259.238054-1-namit@vmware.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 12EDF900009E X-Stat-Signature: afif1bwwyh3m6jzchske8y6uj6hgy46c Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gtU0EfnR; dmarc=pass (policy=none) header.from=gmail.com; spf=none (imf28.hostedemail.com: domain of mail-pj1-f49.google.com has no SPF policy when checking 209.85.216.49) smtp.helo=mail-pj1-f49.google.com X-HE-Tag: 1632699834-45363 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: From: Nadav Amit The goal of these patches is to add support for process_madvise(MADV_DONTNEED). Yet, in the process some (arguably) useful cleanups, a bug fix and performance enhancements are performed. The patches try to consolidate the logic across different behaviors, and to a certain extent overlap/conflict with an outstanding patch that does something similar [1]. This consolidation however is mostly orthogonal to the aforementioned one and done in order to clarify what is done in respect to locks and TLB for each behavior and to batch these operations more efficiently on process_madvise(). process_madvise(MADV_DONTNEED) is useful for two reasons: (a) it allows userfaultfd monitors to unmap memory from monitored processes; and (b) it is more efficient than madvise() since it is vectored and batches TLB flushes more aggressively. The first three patches should not interfere with the outstanding patch [1]. The rest might need to be rebased after [1] is applied. [1] https://lore.kernel.org/linux-mm/CAJuCfpFDBJ_W1y2tqAT4BGtPbWrjjDud_JuKO8ZbnjYfeVNvRg@mail.gmail.com/ Cc: Peter Xu Cc: Andrea Arcangeli Cc: Andrew Morton Cc: Minchan Kim Cc: Colin Cross Cc: Suren Baghdasarya Cc: Mike Rapoport Nadav Amit (8): mm/madvise: propagate vma->vm_end changes mm/madvise: remove unnecessary check on madvise_dontneed_free() mm/madvise: remove unnecessary checks on madvise_free_single_vma() mm/madvise: define madvise behavior in a struct mm/madvise: perform certain operations once on process_madvise() mm/madvise: more aggressive TLB batching mm/madvise: deduplicate code in madvise_dontneed_free() mm/madvise: process_madvise(MADV_DONTNEED) mm/internal.h | 5 + mm/madvise.c | 396 ++++++++++++++++++++++++++++++-------------------- mm/memory.c | 2 +- 3 files changed, 248 insertions(+), 155 deletions(-)