From patchwork Sun Aug 7 15:44:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Lee X-Patchwork-Id: 12938179 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 B9719C19F2A for ; Sun, 7 Aug 2022 15:44:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36FDA8E0002; Sun, 7 Aug 2022 11:44:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31EA48E0001; Sun, 7 Aug 2022 11:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E5D08E0002; Sun, 7 Aug 2022 11:44:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0F4248E0001 for ; Sun, 7 Aug 2022 11:44:48 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D422BAAD81 for ; Sun, 7 Aug 2022 15:44:47 +0000 (UTC) X-FDA: 79773219414.09.3BBDA19 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf16.hostedemail.com (Postfix) with ESMTP id 6EFE9180150 for ; Sun, 7 Aug 2022 15:44:47 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id o5-20020a17090a3d4500b001ef76490983so7025128pjf.2 for ; Sun, 07 Aug 2022 08:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc; bh=sEWroSP5zB4LvyUigg1CpthwDBkI2FfyMg4MRduTBcc=; b=ArNhfPo2gtrRcFzbgbUUN6hfCSVMaHdjl49JJ0ChYL55kMWBh9Dc29zrpVi2f5FCEc UXdtVHu1SCP/6qIoCsCci5OsWtXVCQ2bDSl9ca1sPVfdabmsF1M8yesQ6vDGwTGWCGDf JxylR/jzxfgRNaUhu2oahDfkqWAxa/ThxGw7qRIyixWIDrGZpPo+BaYAp5wvM8GhOarJ 6gvlknkk9cJDqdcNEFKrc0fnu0vkGuCO0jzKBx3ERWYS9ebjMurK2SrGLRlwOdufHrbh 9bbdYasJHI5Cr1/6lEzFE4WM/B7rF6yrn1QKHM4igtRl5/d23++epcORpephEFBZs88B nH9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc; bh=sEWroSP5zB4LvyUigg1CpthwDBkI2FfyMg4MRduTBcc=; b=lqNsHqprdeGGYnQNRacGU8b5KXT6YhpdM9O84JHHC9Uhfx673Y9R8lEEqV7j/bv28U A2MRExzYLC9nxzCwjuNLMO1MKZTgil/HCj7aej0NB7Jf8EC9fM/EPiavlrPxCPIiurnq Albk/a6gf+e7LmeUBGp05zJfUaVesZDmm5PwnC+lsUSRCyD7skNZX+CNWd8BDwl2b8KV uKkfldw9VEh4AdBkmE5DLRl01QpXx9qo0rIV2eh263NdjK07BpyA/37cW6mQ7RS+2SyB 2qaxogOH+3vH4GiFCnu8cWMf739XNotAe7F8YE7qkiVfmeJ67D/DXmn5iMRtpWtpxBAs nJAQ== X-Gm-Message-State: ACgBeo11B7LDg7v7x8Ub6vnAvYtZ7K+ZNpdvh9KjkoTvRZKAnUkGr4g8 uGN3NQ197K/Kj1AYd++8z+8= X-Google-Smtp-Source: AA6agR41ofA7h5HbCueofia2RsCDqXdYTNJIs2PIBro9kl6Wq0wsFr4zBZMmKLm8U48qbDc6in47Uw== X-Received: by 2002:a17:902:ce09:b0:16b:ec52:760b with SMTP id k9-20020a170902ce0900b0016bec52760bmr15031094plg.155.1659887086157; Sun, 07 Aug 2022 08:44:46 -0700 (PDT) Received: from haolee.io ([2600:3c01::f03c:91ff:fe02:b162]) by smtp.gmail.com with ESMTPSA id h2-20020a17090a470200b001f319e9b9e5sm8873860pjg.16.2022.08.07.08.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 08:44:45 -0700 (PDT) Date: Sun, 7 Aug 2022 15:44:42 +0000 From: Hao Lee To: akpm@linux-foundation.org Cc: david@redhat.com, yang.shi@linux.alibaba.com, hannes@cmpxchg.org, haolee.swjtu@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2] mm: add DEVICE_ZONE to FOR_ALL_ZONES Message-ID: <20220807154442.GA18167@haolee.io> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659887087; a=rsa-sha256; cv=none; b=XTxf2HwDg31ERkXzpNUIW3Tj66FnillagOB5AEmvZPH/idSC2vdYY4voYeCKJ6wp5NXw4D k+bXB7xERbTcY2BcG3+sfBrQdUMMVFgLGJBmcwDTE/dfnWOOiGIFkuD0bDBW0zrp/qvoXX Jiv1ftSXZCsVQLpGtZXnuMXFPlvouHc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ArNhfPo2; spf=pass (imf16.hostedemail.com: domain of haolee.swjtu@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=haolee.swjtu@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659887087; 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=sEWroSP5zB4LvyUigg1CpthwDBkI2FfyMg4MRduTBcc=; b=s9mjHNAq20ZXL2yJKOq8HCznDyWLzCLnEVD7wjeUA1d4AcQ4+BcoW7M3444TkqEnmdbfwE 1/Oh4U3Ld1KbvxjrmtOuXtj6zKDVH4Q1ZsSHfA2R6LMmTP7N1+5VpdkLiHYLNb21cEBGRu hiSGWCOHMnPTO+v9967+AelG/oB5zns= X-Rspamd-Queue-Id: 6EFE9180150 X-Rspam-User: X-Rspamd-Server: rspam11 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ArNhfPo2; spf=pass (imf16.hostedemail.com: domain of haolee.swjtu@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=haolee.swjtu@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: pr71biqrinq1q3gjyr9gf6nud91f7te7 X-HE-Tag: 1659887087-92258 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: FOR_ALL_ZONES should be consistent with enum zone_type. Otherwise, __count_zid_vm_events have the potential to add count to wrong item when zid is ZONE_DEVICE. Signed-off-by: Hao Lee --- include/linux/vm_event_item.h | 15 +++++++++++---- mm/vmstat.c | 9 ++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 404024486fa5..f3fc36cd2276 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -20,12 +20,19 @@ #define HIGHMEM_ZONE(xx) #endif -#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL, HIGHMEM_ZONE(xx) xx##_MOVABLE +#ifdef CONFIG_ZONE_DEVICE +#define DEVICE_ZONE(xx) xx##_DEVICE, +#else +#define DEVICE_ZONE(xx) +#endif + +#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL, \ + HIGHMEM_ZONE(xx) xx##_MOVABLE, DEVICE_ZONE(xx) enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, - FOR_ALL_ZONES(PGALLOC), - FOR_ALL_ZONES(ALLOCSTALL), - FOR_ALL_ZONES(PGSCAN_SKIP), + FOR_ALL_ZONES(PGALLOC) + FOR_ALL_ZONES(ALLOCSTALL) + FOR_ALL_ZONES(PGSCAN_SKIP) PGFREE, PGACTIVATE, PGDEACTIVATE, PGLAZYFREE, PGFAULT, PGMAJFAULT, PGLAZYFREED, diff --git a/mm/vmstat.c b/mm/vmstat.c index 373d2730fcf2..90af9a8572f5 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1168,8 +1168,15 @@ int fragmentation_index(struct zone *zone, unsigned int order) #define TEXT_FOR_HIGHMEM(xx) #endif +#ifdef CONFIG_ZONE_DEVICE +#define TEXT_FOR_DEVICE(xx) xx "_device", +#else +#define TEXT_FOR_DEVICE(xx) +#endif + #define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \ - TEXT_FOR_HIGHMEM(xx) xx "_movable", + TEXT_FOR_HIGHMEM(xx) xx "_movable", \ + TEXT_FOR_DEVICE(xx) const char * const vmstat_text[] = { /* enum zone_stat_item counters */