From patchwork Thu Jan 26 19:37:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13117649 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 E04B9C54EAA for ; Thu, 26 Jan 2023 19:38:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 760596B0072; Thu, 26 Jan 2023 14:38:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EA966B0073; Thu, 26 Jan 2023 14:38:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 563B46B0078; Thu, 26 Jan 2023 14:38:00 -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 3F5516B0072 for ; Thu, 26 Jan 2023 14:38:00 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BDFD380F0D for ; Thu, 26 Jan 2023 19:37:59 +0000 (UTC) X-FDA: 80397960678.03.3348230 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf19.hostedemail.com (Postfix) with ESMTP id D37211A0003 for ; Thu, 26 Jan 2023 19:37:57 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sAI3PaCI; spf=pass (imf19.hostedemail.com: domain of 3lNbSYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3lNbSYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@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=1674761877; 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: references:dkim-signature; bh=phHZehQlPfWiz/SCqB6D1h1zjdz8NfMq5LeGu27bEvE=; b=wFN+sG6tYTq5qXfCrwWM5nEJc7E+CZTIT8qYuvq/h0pVkKmHQFdYGrqGm1sDtFIOnYjfhQ s5LnPDD2kBwrAtgqFeS7zrS5fgRC4882V6/JZkLM5SjVBlEriL91p31eGECNQ59kO2q9/l O7YntkwV0giJz29g+U9E0sTiOKn5Iyo= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sAI3PaCI; spf=pass (imf19.hostedemail.com: domain of 3lNbSYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3lNbSYwYKCLEjliVeSXffXcV.TfdcZelo-ddbmRTb.fiX@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674761877; a=rsa-sha256; cv=none; b=3pHR3Zjam7sROM9/TVWMY1pPJ7ih+2iJGdtm7y4UwnbRKM7sJEofZgsV37lK/zLnGWs1GI TpL7jpYLE/0mmtZ37svJKoe9cP3o/xCljG8BBvQJ1W59TbYh8jgRNezBXdxLj932RlCzA9 v+kivF5oL1/dTeQO/8PXnZQCXvaX0kk= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-4d5097a95f5so31257457b3.1 for ; Thu, 26 Jan 2023 11:37:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=phHZehQlPfWiz/SCqB6D1h1zjdz8NfMq5LeGu27bEvE=; b=sAI3PaCI0OUTCw3+G/ENMwMXBu+0JMz5nY32BJWVy5FKAbNNJy+GgrkBpa51OASAI+ hG7AUBHszGhWKNDJK8lN0YysXcGQBAA57BVJvypr7jHcb4003RKRPXpxPxVUP7KlCFZ9 PJUtXMhcdfNLlX0cvXy9QqJG82pjajRp67z9ea2DIOi+nbFZ15F5lxfeksMBcCF5V19z 24BhRFQsVIWOznHK3iTFkeDr1XuFnMQ9go4xzM3hj7VNWp32hsacGT90xuaqKolom3La /NVnvdQ5qEZUSofWJn1rj6AB1JhrFDJjNA4fLKYaO/zIg1BAjVjsTMj/CiNjwb0goIui q2Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=phHZehQlPfWiz/SCqB6D1h1zjdz8NfMq5LeGu27bEvE=; b=Glrtc8nwoeA3yxdz6ATSmpDDTNF2kFUSbAkH0WJ8OehtqoMPwfRjL/lTTwXf4k/60E ChmVYR9m4IR4RrSytw9J6bHSaEHEgHmehlNgLzRHEIz+WAZCslWQVfJGsYV3XkjrV4Sm 3aSVIhxzzhXjg6D8e+82JJ3Wnm+8irj2CtmH0GfYcS0fQ2f5p+M42EjAJjVW7zL5lRwN +IeXbjT5Az1/XSOboUXmfDFgb49ojdIq8y64Iw2O5+CREogCkO+2Tc5S/7U4pFPvRkrF VvTnUAdg1jPSCYvCz3LC+2aXX0VuHB2R08EaDsHd1InMG9Wr/0t+tu9w76gdtf+qmDIw 6c4g== X-Gm-Message-State: AO0yUKWkXBcQb++HhGZU3FtrmU24snMvdedBiAPmnGuuZrvEpah3VfP9 nawoY/jVuVDD1j1hW4FNk7wMyk+WDSI= X-Google-Smtp-Source: AK7set+KL/YFp3NF4pvldDE31DXRDExB/qqIxmCm21ckLcKXHvndueNAPPnb0OtRCT++59brN5tSAdYMshI= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:d774:88af:bab3:648d]) (user=surenb job=sendgmr) by 2002:a81:16cc:0:b0:506:3cd3:7e42 with SMTP id 195-20020a8116cc000000b005063cd37e42mr1740930yww.454.1674761876848; Thu, 26 Jan 2023 11:37:56 -0800 (PST) Date: Thu, 26 Jan 2023 11:37:45 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog Message-ID: <20230126193752.297968-1-surenb@google.com> Subject: [PATCH v4 0/7] introduce vm_flags modifier functions From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, paulmck@kernel.org, mingo@redhat.com, will@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, rppt@kernel.org, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D37211A0003 X-Stat-Signature: zaduwq5bxnpa4cyp7tzc71h3sbna3cu5 X-HE-Tag: 1674761877-987571 X-HE-Meta: U2FsdGVkX18Koth6EfOnzCuCoF9Zggb9RHj42lZpDVarr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Y6wCAQ7WN3VbuWB0YhXt/6L5q3zgxxIGMcHOnE7f4ctVia9/6mRUnPmt0m11OZ/SC5ol24d3R/uyorVP371822JKIK6+hEQEjkROSFRsBMOhY4yGpsBuiJ+T1R69f/lU5+23aEXF4L3kMD47mkUtw/oBOmpOOw6kYNd+1nK9Tvs1Ibc5tmWo2Sx6+fVURj/V6wV43GErF6yfymJetTuiGAjawf5n2ajm73LC1/kJwHg5iR5sHmAnPlajO7mmdvqVfacWu6HRTe+LqDLAgSV1VbCI3vwOtRkuzRalU1VoK9OYFZmB3SicLN970O3/bXvYgIfG3tLNfyDbe9rCzutlXtaE4ws/jyVT0whjT2wP9fAqD7yBn744lIUfisyv2t/O1bCDE8D8ygiaSKe6ao95Ssrg/rZZGK5czjsOhfOXLGRJhljh2msnsgOzcVj7KpPlZmf3b8c3bZVBsB43zVkzB8Zs6LIvM+bWct3xPdfWAEVMdAtxj56kVJIhyTvvnzsUC2c6/unXXDCZKNd31HaAQZa7MMFqN2v4qf1FDu5T6hep2iefFwt7NRumHjUZSdEuknEcUjHingoVqJbc08NzLrcp+oO76N6NaVSFOq23Bad8= 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: This patchset was originally published as a part of per-VMA locking [1] and was split after suggestion that it's viable on its own and to facilitate the review process. It is now a preprequisite for the next version of per-VMA lock patchset, which reuses vm_flags modifier functions to lock the VMA when vm_flags are being updated. VMA vm_flags modifications are usually done under exclusive mmap_lock protection because this attrubute affects other decisions like VMA merging or splitting and races should be prevented. Introduce vm_flags modifier functions to enforce correct locking. The patchset applies cleanly over mm-unstable branch of mm tree. Changes since v3 [2] - Fixed build breakage in nommu.c introduced in previous version, per Andrew Morton - Added back data_race() hint in vm_area_dup, per Mel Gorman - Renamed vm_flags modifiers, per Andrew Morton, Mike Rapoport and Mel Gorman - Changed vm_flags_mod to reset vm_flags with one assignment, per Mel Gorman - Added comments about the need to copy vm_flags before ksm_madvise, per Mel Gorman - Added clarifications for __vm_flags_mod usage, per Mel Gorman [1] https://lore.kernel.org/all/20230109205336.3665937-1-surenb@google.com/ [2] https://lore.kernel.org/lkml/20230125233554.153109-1-surenb@google.com/ Suren Baghdasaryan (7): kernel/fork: convert vma assignment to a memcpy mm: introduce vma->vm_flags wrapper functions mm: replace VM_LOCKED_CLEAR_MASK with VM_LOCKED_MASK mm: replace vma->vm_flags direct modifications with modifier calls mm: replace vma->vm_flags indirect modification in ksm_madvise mm: introduce __vm_flags_mod and use it in untrack_pfn mm: export dump_mm() arch/arm/kernel/process.c | 2 +- arch/ia64/mm/init.c | 8 +-- arch/loongarch/include/asm/tlb.h | 2 +- arch/powerpc/kvm/book3s_hv_uvmem.c | 6 +- arch/powerpc/kvm/book3s_xive_native.c | 2 +- arch/powerpc/mm/book3s64/subpage_prot.c | 2 +- arch/powerpc/platforms/book3s/vas-api.c | 2 +- arch/powerpc/platforms/cell/spufs/file.c | 14 ++--- arch/s390/mm/gmap.c | 9 ++- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/kernel/cpu/sgx/driver.c | 2 +- arch/x86/kernel/cpu/sgx/virt.c | 2 +- arch/x86/mm/pat/memtype.c | 14 +++-- arch/x86/um/mem_32.c | 2 +- drivers/acpi/pfr_telemetry.c | 2 +- drivers/android/binder.c | 3 +- drivers/char/mspec.c | 2 +- drivers/crypto/hisilicon/qm.c | 2 +- drivers/dax/device.c | 2 +- drivers/dma/idxd/cdev.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 +- drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c | 4 +- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 4 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 +- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_gem_dma_helper.c | 3 +- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- drivers/gpu/drm/drm_vm.c | 8 +-- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 4 +- drivers/gpu/drm/gma500/framebuffer.c | 2 +- drivers/gpu/drm/i810/i810_dma.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 4 +- drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 +- drivers/gpu/drm/msm/msm_gem.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 3 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 3 +- drivers/gpu/drm/tegra/gem.c | 5 +- drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 +- drivers/gpu/drm/virtio/virtgpu_vram.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | 2 +- drivers/gpu/drm/xen/xen_drm_front_gem.c | 3 +- drivers/hsi/clients/cmt_speech.c | 2 +- drivers/hwtracing/intel_th/msu.c | 2 +- drivers/hwtracing/stm/core.c | 2 +- drivers/infiniband/hw/hfi1/file_ops.c | 4 +- drivers/infiniband/hw/mlx5/main.c | 4 +- drivers/infiniband/hw/qib/qib_file_ops.c | 13 ++--- drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 2 +- .../infiniband/hw/vmw_pvrdma/pvrdma_verbs.c | 2 +- .../common/videobuf2/videobuf2-dma-contig.c | 2 +- .../common/videobuf2/videobuf2-vmalloc.c | 2 +- drivers/media/v4l2-core/videobuf-dma-contig.c | 2 +- drivers/media/v4l2-core/videobuf-dma-sg.c | 4 +- drivers/media/v4l2-core/videobuf-vmalloc.c | 2 +- drivers/misc/cxl/context.c | 2 +- drivers/misc/habanalabs/common/memory.c | 2 +- drivers/misc/habanalabs/gaudi/gaudi.c | 4 +- drivers/misc/habanalabs/gaudi2/gaudi2.c | 8 +-- drivers/misc/habanalabs/goya/goya.c | 4 +- drivers/misc/ocxl/context.c | 4 +- drivers/misc/ocxl/sysfs.c | 2 +- drivers/misc/open-dice.c | 4 +- drivers/misc/sgi-gru/grufile.c | 4 +- drivers/misc/uacce/uacce.c | 2 +- drivers/sbus/char/oradax.c | 2 +- drivers/scsi/cxlflash/ocxl_hw.c | 2 +- drivers/scsi/sg.c | 2 +- .../staging/media/atomisp/pci/hmm/hmm_bo.c | 2 +- drivers/staging/media/deprecated/meye/meye.c | 4 +- .../media/deprecated/stkwebcam/stk-webcam.c | 2 +- drivers/target/target_core_user.c | 2 +- drivers/uio/uio.c | 2 +- drivers/usb/core/devio.c | 3 +- drivers/usb/mon/mon_bin.c | 3 +- drivers/vdpa/vdpa_user/iova_domain.c | 2 +- drivers/vfio/pci/vfio_pci_core.c | 2 +- drivers/vhost/vdpa.c | 2 +- drivers/video/fbdev/68328fb.c | 2 +- drivers/video/fbdev/core/fb_defio.c | 4 +- drivers/xen/gntalloc.c | 2 +- drivers/xen/gntdev.c | 4 +- drivers/xen/privcmd-buf.c | 2 +- drivers/xen/privcmd.c | 4 +- fs/aio.c | 2 +- fs/cramfs/inode.c | 2 +- fs/erofs/data.c | 2 +- fs/exec.c | 4 +- fs/ext4/file.c | 2 +- fs/fuse/dax.c | 2 +- fs/hugetlbfs/inode.c | 4 +- fs/orangefs/file.c | 3 +- fs/proc/task_mmu.c | 2 +- fs/proc/vmcore.c | 3 +- fs/userfaultfd.c | 2 +- fs/xfs/xfs_file.c | 2 +- include/linux/mm.h | 58 +++++++++++++++++-- include/linux/mm_types.h | 10 +++- include/linux/pgtable.h | 5 +- kernel/bpf/ringbuf.c | 4 +- kernel/bpf/syscall.c | 4 +- kernel/events/core.c | 2 +- kernel/fork.c | 4 +- kernel/kcov.c | 2 +- kernel/relay.c | 2 +- mm/debug.c | 1 + mm/hugetlb.c | 4 +- mm/madvise.c | 2 +- mm/memory.c | 19 +++--- mm/memremap.c | 4 +- mm/mlock.c | 12 ++-- mm/mmap.c | 32 +++++----- mm/mprotect.c | 2 +- mm/mremap.c | 8 +-- mm/nommu.c | 11 ++-- mm/secretmem.c | 2 +- mm/shmem.c | 2 +- mm/vmalloc.c | 2 +- net/ipv4/tcp.c | 4 +- security/selinux/selinuxfs.c | 6 +- sound/core/oss/pcm_oss.c | 2 +- sound/core/pcm_native.c | 9 +-- sound/soc/pxa/mmp-sspa.c | 2 +- sound/usb/usx2y/us122l.c | 4 +- sound/usb/usx2y/usX2Yhwdep.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 127 files changed, 300 insertions(+), 234 deletions(-) Acked-by: Mike Rapoport (IBM)