Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3065325lqp; Mon, 25 Mar 2024 19:40:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+f9AyOEUAL8rKDJmHL9w0gdPtGc5pKOFskZrxK9jR1FyafTYnmXjCoXXnAUgW8nnjmVtQa6oJ/yWaI0akBhpCYcFB8uTny86xMOlhog== X-Google-Smtp-Source: AGHT+IEE0mcHPR0b5g+CQXB3si9BIhER0ssFMojQZernhYsYHVqRD4Qo1QgLbfHckJQ3iQScQUot X-Received: by 2002:a05:6871:7a2:b0:22a:228d:c0a2 with SMTP id o34-20020a05687107a200b0022a228dc0a2mr1788406oap.6.1711420853705; Mon, 25 Mar 2024 19:40:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711420853; cv=pass; d=google.com; s=arc-20160816; b=UjoyW0Q/nnce5HRqQ4+yFdA+V8cotzC4Mkdh8g7bqYOikmv58Qax7wvxKaHTutE4mV Rrw6HpbUlspJ5PJegr1c5UAOghqDTwqDwmLY2XdLugQ9rPUkWCDCsN5DE11+Sa2f0fRT j1WJcf+2j3rxgdFtv3/JaKN6QEaMkGCwFNn6+ald2jhEsM/cfh38q2hEhHroUc0AysbD L3XMR+gokRJ/oPTXEIZqnQiK8mye583RNbhTd9La0GWNHdqBi/2tEuwAEy8Vi68+gUC4 5RfEFipoFxssQlcXeTFuXxHlLneozhImh9zdjpU43/D3xTwmAkrrpjlnH5FQ1EPT9L8S OnoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=tjwkluIVfDTIsp4UcND1T82W1UbcVehjQk3vVVPkQQE=; fh=hrlWvyh2+2+qtYSDS74IWbwD2TgzeHtygwXvTncL5J0=; b=VOzwf9AY5LD2Tq/L+Gjn9DbnEIw81uR+XefFxcbFHnya5Ry38T6i3OKt6PyUtYOVdf fyxbWjcDjBame3lmX0vrn1OhZaOHJ+cx5cUynVFOtj2Di8ydaMnorVN0Lp4PA4YGQn/d 4Ad7RnqTaNApJulxtWJNpHPKVeRAJlV/3O2x6LNcFtelUWOBpSj3vEh8w7vOJ8kS79Zo LQKzheVuCbRq4eDw/CV5ekAN1XABwbT4xJeeidXJeDIyre33Bmub8SrdnXY0Rd7ote5g U6zwrWKcuAjqrCAUsOhusz8/a69SRaTHyORcUkUpzxChLr/TjEhNpgX+ARQK6UY6QjAE hSyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XRML10vk; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-118310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n6-20020aa79846000000b006eabc1f0602si109128pfq.124.2024.03.25.19.40.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 19:40:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XRML10vk; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-118310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 257ADB2325D for ; Tue, 26 Mar 2024 02:40:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2526112838A; Tue, 26 Mar 2024 02:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XRML10vk" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 180161D53C for ; Tue, 26 Mar 2024 02:39:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711420801; cv=none; b=DykioSnZxKKHL1uXBrwGSadzw8Dc5Mff6D8bDy8gHfD2o8ZEyWsbUn/yQiue+yMiBxgRlgbhtSpPAHJhU5Mb2dIk+jhLvoZAjP4ub/Irj00OZIu976fn8KnMnDDDt0fuAZuCT3fpr//MuCBuXj2WT0CfUE4yliHRdWklMnG92hY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711420801; c=relaxed/simple; bh=a+rFEOl+Jv1er7xV3rfzd9s10Ay9aPwSRWomvQxiApg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=MQKSCbl4veDQZcKUqankIHt546vIIjwfNk8chJEKnHLndOr4rQZ/HLfVSNgcHaaDXyPDYnzabUDMzRHmHcHswC/i4Ud/BkOq72B8IdE9fBH6nyRlG+8YBH0QcIerhkN+nLTj8mMU1oTjPL18fOHDTIegkJrXWo4HQTzYCsQes6U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XRML10vk; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711420799; x=1742956799; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=a+rFEOl+Jv1er7xV3rfzd9s10Ay9aPwSRWomvQxiApg=; b=XRML10vk93HTLGUKLxFkihN7/cbNzWOw/hisAzwbGJjLjqqde2eEAOeB 1PJvz1BPqO0pgzLTqLjh9k6PQwgTZEqbfo1RtswTVaaGM9Lp689Fd+8Sg stl2ulzBwzGZL9jDKZ2Ikg/pfnZmU6xhG7+PUo6oC2tcVWm6rqMGXdUJ/ RPEIs3UwERjhlbeCfi8IEdfLnX/IO82UW2hS0fcquIjmpRXhE209nPKSj NRRs0H+Iq35cSCyFvxSxhDK9zuMIMZwfgdZFlRiP6gnvaQ51jZ7mMIEia O/lLJmtGEG5yi2YvYkIc0SYf9p085jkIDWgxsavcB8onnH8ypXMHWw0a5 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11024"; a="10248324" X-IronPort-AV: E=Sophos;i="6.07,155,1708416000"; d="scan'208";a="10248324" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 19:39:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,155,1708416000"; d="scan'208";a="15879132" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 19:39:53 -0700 From: "Huang, Ying" To: Donet Tom Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Aneesh Kumar , Michal Hocko , Dave Hansen , Mel Gorman , Feng Tang , Andrea Arcangeli , Peter Zijlstra , Ingo Molnar , Rik van Riel , Johannes Weiner , Matthew Wilcox , Vlastimil Babka , Dan Williams , Hugh Dickins , Kefeng Wang , Suren Baghdasaryan Subject: Re: [PATCH v4 0/2] Allow migrate on protnone reference with MPOL_PREFERRED_MANY policy In-Reply-To: (Donet Tom's message of "Mon, 25 Mar 2024 09:24:12 -0500") References: Date: Tue, 26 Mar 2024 10:38:00 +0800 Message-ID: <875xx9pvjr.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Donet Tom writes: > This patchset is to optimize the cross-socket memory access with > MPOL_PREFERRED_MANY policy. > > To test this patch we ran the following test on a 3 node system. > Node 0 - 2GB - Tier 1 > Node 1 - 11GB - Tier 1 > Node 6 - 10GB - Tier 2 > > Below changes are made to memcached to set the memory policy, > It select Node0 and Node1 as preferred nodes. > > #include > #include > > unsigned long nodemask; > int ret; > > nodemask = 0x03; > ret = set_mempolicy(MPOL_PREFERRED_MANY | MPOL_F_NUMA_BALANCING, > &nodemask, 10); > /* If MPOL_F_NUMA_BALANCING isn't supported, > * fall back to MPOL_PREFERRED_MANY */ > if (ret < 0 && errno == EINVAL){ > printf("set mem policy normal\n"); > ret = set_mempolicy(MPOL_PREFERRED_MANY, &nodemask, 10); > } > if (ret < 0) { > perror("Failed to call set_mempolicy"); > exit(-1); > } > > Test Procedure: > =============== > 1. Make sure memory tiering and demotion are enabled. > 2. Start memcached. > > # ./memcached -b 100000 -m 204800 -u root -c 1000000 -t 7 > -d -s "/tmp/memcached.sock" > > 3. Run memtier_benchmark to store 3200000 keys. > > #./memtier_benchmark -S "/tmp/memcached.sock" --protocol=memcache_binary > --threads=1 --pipeline=1 --ratio=1:0 --key-pattern=S:S --key-minimum=1 > --key-maximum=3200000 -n allkeys -c 1 -R -x 1 -d 1024 > > 4. Start a memory eater on node 0 and 1. This will demote all memcached > pages to node 6. > 5. Make sure all the memcached pages got demoted to lower tier by reading > /proc//numa_maps. > > # cat /proc/2771/numa_maps > --- > default anon=1009 dirty=1009 active=0 N6=1009 kernelpagesize_kB=64 > default anon=1009 dirty=1009 active=0 N6=1009 kernelpagesize_kB=64 > --- > > 6. Kill memory eater. > 7. Read the pgpromote_success counter. > 8. Start reading the keys by running memtier_benchmark. > > #./memtier_benchmark -S "/tmp/memcached.sock" --protocol=memcache_binary > --pipeline=1 --distinct-client-seed --ratio=0:3 --key-pattern=R:R > --key-minimum=1 --key-maximum=3200000 -n allkeys > --threads=64 -c 1 -R -x 6 > > 9. Read the pgpromote_success counter. > > Test Results: > ============= > Without Patch > ------------------ > 1. pgpromote_success before test > Node 0: pgpromote_success 11 > Node 1: pgpromote_success 140974 > > pgpromote_success after test > Node 0: pgpromote_success 11 > Node 1: pgpromote_success 140974 > > 2. Memtier-benchmark result. > AGGREGATED AVERAGE RESULTS (6 runs) > ================================================================== > Type Ops/sec Hits/sec Misses/sec Avg. Latency p50 Latency > ------------------------------------------------------------------ > Sets 0.00 --- --- --- --- > Gets 305792.03 305791.93 0.10 0.18949 0.16700 > Waits 0.00 --- --- --- --- > Totals 305792.03 305791.93 0.10 0.18949 0.16700 > > ====================================== > p99 Latency p99.9 Latency KB/sec > ------------------------------------- > --- --- 0.00 > 0.44700 1.71100 11542.69 > --- --- --- > 0.44700 1.71100 11542.69 > > With Patch > --------------- > 1. pgpromote_success before test > Node 0: pgpromote_success 5 > Node 1: pgpromote_success 89386 > > pgpromote_success after test > Node 0: pgpromote_success 57895 > Node 1: pgpromote_success 141463 > > 2. Memtier-benchmark result. > AGGREGATED AVERAGE RESULTS (6 runs) > ==================================================================== > Type Ops/sec Hits/sec Misses/sec Avg. Latency p50 Latency > -------------------------------------------------------------------- > Sets 0.00 --- --- --- --- > Gets 521942.24 521942.07 0.17 0.11459 0.10300 > Waits 0.00 --- --- --- --- > Totals 521942.24 521942.07 0.17 0.11459 0.10300 > > ======================================= > p99 Latency p99.9 Latency KB/sec > --------------------------------------- > --- --- 0.00 > 0.23100 0.31900 19701.68 > --- --- --- > 0.23100 0.31900 19701.68 > > > Test Result Analysis: > ===================== > 1. With patch we could observe pages are getting promoted. > 2. Memtier-benchmark results shows that, with the patch, > performance has increased more than 50%. > > Ops/sec without fix - 305792.03 > Ops/sec with fix - 521942.24 > > Changes: > V4 > - Added an example in the "PATCH 2/2" commit message as per the discussion > from V3. > V3: > - Added "* @vmf: structure describing the fault" comment for > mpol_misplaced() to fix the warning. > https://lore.kernel.org/oe-kbuild-all/202403202229.WZeAnUuO-lkp@intel.com/ > -https://lore.kernel.org/lkml/cover.1711002865.git.donettom@linux.ibm.com/ > v2: > - Rebased on latest upstream (v6.8-rc7) > - Used 'numa_node_id()' to get the current execution node ID, Added > 'lockdep_assert_held' to make sure that the 'mpol_misplaced()' is > called with ptl held. > - The migration condition has been updated; now, migration will only > occur if the execution node is present in the policy nodemask. > -https://lore.kernel.org/lkml/cover.1709909210.git.donettom@linux.ibm.com/ > > -v1: https://lore.kernel.org/linux-mm/9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com/#t > > > Donet Tom (2): > mm/mempolicy: Use numa_node_id() instead of cpu_to_node() > mm/numa_balancing:Allow migrate on protnone reference with > MPOL_PREFERRED_MANY policy > > include/linux/mempolicy.h | 5 +++-- > mm/huge_memory.c | 2 +- > mm/internal.h | 2 +- > mm/memory.c | 8 +++++--- > mm/mempolicy.c | 36 +++++++++++++++++++++++++++--------- > 5 files changed, 37 insertions(+), 16 deletions(-) LGTM, Thanks! Feel free to add Reviewed-by: "Huang, Ying" in the future version. -- Best Regards, Huang, Ying