From patchwork Sat Apr 22 20:54:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13221119 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 52B2DC7618E for ; Sat, 22 Apr 2023 20:54:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99FF96B0074; Sat, 22 Apr 2023 16:54:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94E6E6B0072; Sat, 22 Apr 2023 16:54:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 704506B0075; Sat, 22 Apr 2023 16:54:44 -0400 (EDT) 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 5B10D6B0072 for ; Sat, 22 Apr 2023 16:54:44 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 22F1E1C61A5 for ; Sat, 22 Apr 2023 20:54:44 +0000 (UTC) X-FDA: 80710230888.23.FECF4C4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 67E3E120007 for ; Sat, 22 Apr 2023 20:54:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cfML5RRT; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682196882; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=MmovEZDh3RRZ4TGij6AOUtYqNZkl+ysd7uj3ZrA1KLk=; b=Pbw4T6lWBVVRF1xlH/99dKTuEn2q/PM8dk4yjosKrPJoNY/OewilwzvNv215lRMMW1BF6c eQD6LOHoSTlQGLXxEMYuhFxKNy+znC76oIz315MbMLOCq8dlVaauw8I0R22iEZzr+KYy+/ vYFXRk3SnV6EWLpJe9PEKygcTIW6qzE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682196882; a=rsa-sha256; cv=none; b=hyLzo8pMaMDYmPB35cMAB18X+yHL+DBHHRSUYPwh/RL1Rji70naR6IWKKgjIDIV8v/eAJU X6e+Ol1o/2UL1HMe3PAJdhdp5PxSHxP3aY1x0myFIK26cKpFQBIV4KS5HP5DQ2X1vNzkKH te89BAkgag8g9+OE7xKf06tDV1q6RLA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cfML5RRT; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682196881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MmovEZDh3RRZ4TGij6AOUtYqNZkl+ysd7uj3ZrA1KLk=; b=cfML5RRTYwaSpldq14TbO69M0UuKMg99/BUXJH2tz0nCGg/whh98RwMAe8byY2euv5z/+h bGN+DPqJb2S0gu8nusR+FO49iAFSZ9MfoUUVgWHb320hwS9RvPv8Q7M01YWXeVRijXrbds B9pA3FoD1PUK8RomHQWfwVrvAneJTsg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-573-6F8RbvXvPe2iBIeR5XH5sQ-1; Sat, 22 Apr 2023 16:54:35 -0400 X-MC-Unique: 6F8RbvXvPe2iBIeR5XH5sQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B6D4D101A531; Sat, 22 Apr 2023 20:54:34 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.192.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F7F6492B03; Sat, 22 Apr 2023 20:54:21 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org, David Hildenbrand , Andrew Morton , Stefan Roesch , Rik van Riel , Johannes Weiner , Michal Hocko , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Sven Schnelle , Shuah Khan Subject: [PATCH mm-stable v2 0/3] mm/ksm: improve PR_SET_MEMORY_MERGE=0 handling and cleanup disabling KSM Date: Sat, 22 Apr 2023 22:54:17 +0200 Message-Id: <20230422205420.30372-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Queue-Id: 67E3E120007 X-Rspamd-Server: rspam09 X-Stat-Signature: qrafhrdtybykchxomj9e1ch8i1yecagd X-HE-Tag: 1682196882-448996 X-HE-Meta: U2FsdGVkX19uvRS9vJG0Wtsp8Ty3SVq//BCJNsnEq4CKZf2gHSynJSjjlmuew2WJM6WL/ZgBkRnbnOc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bhbZXjAw0J1u2XfCavtNwVNQFj+bff4EEI8Ur77ei2KeJ+R/rI6OYUuP3vm+WokavYMZkzcLYhQpmRbuvjxaaNDFuEaN6jD/I9trutLBkIddtq/AiTD18OXp1sGcm+ttlz9iRat8q9UYO0+S+3E8ujkxwsgAMSmi04ZIpzmPMzASvJMusZqHuA/A0D8kIRQXdFwlbD0ts+fkCbTu7MAzT34P1/bZkGT38vUb8AogPgKyKpA5SeYd8ac3ytBlniHj8q2XBXDjo3Y/XAmOXfIrluejbVTopfM15KW9lJjr5/4DP3iNRGws1R3QsxzNhjKdztj5G/upBvGp0+fjhgLmvKv/G2fdZZjkM= 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 is a follow-up to [1]: [PATCH v9 0/3] mm: process/cgroup ksm support which is now in mm-stable. Ideally we'd get at least patch #1 into the same kernel release as [1], so the semantics of setting PR_SET_MEMORY_MERGE=0 are unchanged between kernel versions. (1) Make PR_SET_MEMORY_MERGE=0 unmerge pages like setting MADV_UNMERGEABLE does, (2) add a selftest for it and (3) factor out disabling of KSM from s390/gmap code. v1 -> v2: - "mm/ksm: unmerge and clear VM_MERGEABLE when setting PR_SET_MEMORY_MERGE=0" -> Cleanup one if/else -> Add doc for ksm_disable_merge_any() - Added ACKs [1] https://lkml.kernel.org/r/20230418051342.1919757-1-shr@devkernel.io Cc: Andrew Morton Cc: Stefan Roesch Cc: Rik van Riel Cc: Johannes Weiner Cc: Michal Hocko Cc: Christian Borntraeger Cc: Janosch Frank Cc: Claudio Imbrenda Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Sven Schnelle Cc: Shuah Khan David Hildenbrand (3): mm/ksm: unmerge and clear VM_MERGEABLE when setting PR_SET_MEMORY_MERGE=0 selftests/ksm: ksm_functional_tests: add prctl unmerge test mm/ksm: move disabling KSM from s390/gmap code to KSM code arch/s390/mm/gmap.c | 20 +----- include/linux/ksm.h | 7 ++ kernel/sys.c | 12 +--- mm/ksm.c | 70 +++++++++++++++++++ .../selftests/mm/ksm_functional_tests.c | 46 ++++++++++-- 5 files changed, 121 insertions(+), 34 deletions(-)