From patchwork Wed Sep 22 04:17:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12509425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AB4BC433EF for ; Wed, 22 Sep 2021 04:18:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 353DD61156 for ; Wed, 22 Sep 2021 04:18:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 353DD61156 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id CF78E6B0072; Wed, 22 Sep 2021 00:18:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C80056B0073; Wed, 22 Sep 2021 00:18:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF8FC6B0074; Wed, 22 Sep 2021 00:18:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id A0FE66B0072 for ; Wed, 22 Sep 2021 00:18:13 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6B3322FD81 for ; Wed, 22 Sep 2021 04:18:13 +0000 (UTC) X-FDA: 78613902066.28.96916F6 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) by imf12.hostedemail.com (Postfix) with ESMTP id F006610000B0 for ; Wed, 22 Sep 2021 04:18:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZ1f50D7Z8SNFn3BQbF/kcuEXAuzchww8nu1wC4si02qqaFtv5vHFI1EcGff0iMop5bBqrg2LN0Bu23HvVOTnkEDgpF4CMI9VDG5dnz6/wjiEpFB03tGb1xUDOTgcxqGN93z9IkvE2pRzWEUxuSjaJbvneVCxxRSzf8zkjbrm3FD5XzindeUTVaAxET4BgYnPy6xKt8MKjLjJcIAtbvl3GZ4ZPJLqq9gt7WwVpJ7UV8TZRqesdWl1Hdhvs1xHZg28bVKVz+JBlQBK+ay2izwy7JdI+3Jl9Q6slERvQ+7+h2+KYb31BjhpG3x9NGpWf+PBpK2q75vR3tPTS+mlRyXGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Xtwuq+Q9u+B/2e+C7AkO0NL3vEY1c4KM7CbuBb29cfs=; b=E8ose+9iaSN49NjB1jRQZtSrxIEPl0gS2WZCbtXrJH+uu61g//9FHV5MaEg680AKeNvzFZd8fSJKEAsy+BJe5mde5m+NXnaEZ8YSFv0nqybnA3I3RYVH1zDuVupCiVmu4tIgfhJAE+CEuFkYt+gh9ffpZFsKO+nltxPbq7hSjaq5GwLY+dSV5N5O7x6jU67xeaepccEd0UiWseJH8I2G9S5uCDFhWAcWIJJNXXpUSPhb/+rbdki+qmqa8q3ScjrvbalLxqgipSepXojub4weejvsWv5ukfnF92ET9nDaEi3B3ggLUvfq5BD7UmZdCbYaOqEr1NCAzKfWvyXHnlBmjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=soleen.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xtwuq+Q9u+B/2e+C7AkO0NL3vEY1c4KM7CbuBb29cfs=; b=hCDxEAFRsJpQGSBa4MLrJLwH2sFC5/2aZxMgmfN/iyrVuL1HOdcoIX/QKWnpX1DUJGcIjj+NzFY8MtJotdxyuJbElDVYgjsRC2N1eWcfpoJ49xDbS4o92H9jmLZcuRk5m/NVl+j0AIgHGKnqfsCbRh9HlaOEN06H0tD8eUbxMhD8NqG0PhBUd6xSi3AeeCoGyKQaH3eVP4Ux9zRNL4FolkZx7DljQSdNT9IHd/lsnXU5tV7G7JU9M07f7HTf9hLMiNhph/Pauhkr3zkcxSHLHu6NknAvmN+GH+S9rmzn3XNqbSUutg6ias2RuQAiNk/FK7veMzLw9yNhbI5RpbGEfg== Received: from BN9PR03CA0488.namprd03.prod.outlook.com (2603:10b6:408:130::13) by MN2PR12MB3901.namprd12.prod.outlook.com (2603:10b6:208:16c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 22 Sep 2021 04:18:09 +0000 Received: from BN8NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:408:130:cafe::c3) by BN9PR03CA0488.outlook.office365.com (2603:10b6:408:130::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Wed, 22 Sep 2021 04:18:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; soleen.com; dkim=none (message not signed) header.d=none;soleen.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by BN8NAM11FT034.mail.protection.outlook.com (10.13.176.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Wed, 22 Sep 2021 04:18:09 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 22 Sep 2021 04:18:08 +0000 Received: from sandstorm.attlocal.net (172.20.187.6) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 21 Sep 2021 21:18:08 -0700 From: John Hubbard To: CC: , , , , , , , , , , , , , , , Subject: [PATCH 1/1] mm/migrate: de-duplicate migrate_reason strings Date: Tue, 21 Sep 2021 21:17:55 -0700 Message-ID: <20210922041755.141817-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210922041755.141817-1-jhubbard@nvidia.com> References: <20210922041755.141817-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34fa18d5-eee9-4133-5631-08d97d7ffc37 X-MS-TrafficTypeDiagnostic: MN2PR12MB3901: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9nPnDEp94VuvgpyDTdI8Iog/AJrWc1PPLzmMY/zdjWB58OmdXOi4kSw1R1wIKBhtKVECszMDCm8By8PTdIm0c2oPoWH2Te6fcPk4Ev4X1Xk99w9FnYmVS0mFNiD+9R3HoSgGDju3SHHS7rgRYZKAkJ+AUidAbr3wCAsvG/4VWM6Zsl2rb1bXoYOWKVht3kZ7HawOjeFxMu0txVASbh48POzzH6t47C0gXW3Q0UToiFRJ2HK3S+HYyZ7A0e13DzgXw2Qi0+tlbFqyJCvQWYIYkjVxDlMawYnLh4BzdNFDOlTwBWp5yMXoacH3CmfvL0ftwU3aE0rGTypWHNo1Z7x93fEE/hYq6kPi/gBqVTEWiAlSTAAAmnruJQmHFy0ZzYJbVjRaUNHks/7C8lh8cIbOWBIsVuapaTIFA8L6crL9fhVYWHVSfGFlSamaqupqHugU/uMXvLDk+WTI3YjhZe2/39qOKPFXj89k/t+H0yAt2VAU6HYPYLWNWumVBxqLquqEwtXB+LtesN9I6vOfN1zhSfq68S0VNU9xzvp6j5dW9ycWUebp9dhfkHD7NDA1wU77xiUGmGY9g9UFvdQsri3MhnplgG4neSI24qQiJcZ7K7OBJcywICL3jo4USmZ7ybQoAdZu9UmCah22BsCegI7B1Fzz3RD2HZacuj9HpCJvQt7Ru0RglFAiTlY+gFozH0PGEXSMte/jxKSs/VAhKj6Ugg== X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(36756003)(1076003)(70586007)(7636003)(70206006)(356005)(83380400001)(508600001)(2616005)(36906005)(5660300002)(86362001)(7416002)(4326008)(107886003)(336012)(54906003)(47076005)(426003)(6916009)(186003)(2906002)(6666004)(316002)(82310400003)(8676002)(8936002)(26005)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2021 04:18:09.3780 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34fa18d5-eee9-4133-5631-08d97d7ffc37 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3901 X-Stat-Signature: 5kpnrdxhodo88uza6mybmhemozmdgow1 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=hCDxEAFR; dmarc=pass (policy=quarantine) header.from=nvidia.com; spf=none (imf12.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.220.60) smtp.mailfrom=jhubbard@nvidia.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: F006610000B0 X-HE-Tag: 1632284292-751427 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: In order to remove the need to manually keep three different files in synch, provide a common definition of the mapping between enum migrate_reason, and the associated strings for each enum item. 1. Use the tracing system's mapping of enums to strings, by redefining and reusing the MIGRATE_REASON and supporting macros, and using that to populate the string array in mm/debug.c. 2. Move enum migrate_reason to migrate_mode.h. This is not strictly necessary for this patch, but migrate mode and migrate reason go together, so this will slightly clarify things. Cc: Weizhao Ouyang Cc: "Huang, Ying" Signed-off-by: John Hubbard Reviewed-by: Weizhao Ouyang --- include/linux/migrate.h | 19 +------------------ include/linux/migrate_mode.h | 13 +++++++++++++ mm/debug.c | 20 +++++++++++--------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index c8077e936691..3d154fe03c96 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -19,24 +19,7 @@ struct migration_target_control; */ #define MIGRATEPAGE_SUCCESS 0 -/* - * Keep sync with: - * - macro MIGRATE_REASON in include/trace/events/migrate.h - * - migrate_reason_names[MR_TYPES] in mm/debug.c - */ -enum migrate_reason { - MR_COMPACTION, - MR_MEMORY_FAILURE, - MR_MEMORY_HOTPLUG, - MR_SYSCALL, /* also applies to cpusets */ - MR_MEMPOLICY_MBIND, - MR_NUMA_MISPLACED, - MR_CONTIG_RANGE, - MR_LONGTERM_PIN, - MR_DEMOTION, - MR_TYPES -}; - +/* Defined in mm/debug.c: */ extern const char *migrate_reason_names[MR_TYPES]; #ifdef CONFIG_MIGRATION diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h index 883c99249033..f37cc03f9369 100644 --- a/include/linux/migrate_mode.h +++ b/include/linux/migrate_mode.h @@ -19,4 +19,17 @@ enum migrate_mode { MIGRATE_SYNC_NO_COPY, }; +enum migrate_reason { + MR_COMPACTION, + MR_MEMORY_FAILURE, + MR_MEMORY_HOTPLUG, + MR_SYSCALL, /* also applies to cpusets */ + MR_MEMPOLICY_MBIND, + MR_NUMA_MISPLACED, + MR_CONTIG_RANGE, + MR_LONGTERM_PIN, + MR_DEMOTION, + MR_TYPES +}; + #endif /* MIGRATE_MODE_H_INCLUDED */ diff --git a/mm/debug.c b/mm/debug.c index fae0f81ad831..4333b6784a20 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -16,17 +16,19 @@ #include #include "internal.h" +#include + +/* + * Define EM() and EMe() so that MIGRATE_REASON from trace/events/migrate.h can + * be used to populate migrate_reason_names[]. + */ +#undef EM +#undef EMe +#define EM(a, b) b, +#define EMe(a, b) b const char *migrate_reason_names[MR_TYPES] = { - "compaction", - "memory_failure", - "memory_hotplug", - "syscall_or_cpuset", - "mempolicy_mbind", - "numa_misplaced", - "contig_range", - "longterm_pin", - "demotion", + MIGRATE_REASON }; const struct trace_print_flags pageflag_names[] = {