Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1418248ybj; Fri, 8 May 2020 00:29:56 -0700 (PDT) X-Google-Smtp-Source: APiQypKM0cLdBkYX0QFAV4yBwvEgnOfuXFie7NryVbqcLOlB7UnhX9JybmyF/9Uh3pQ8mTiIQzXw X-Received: by 2002:a50:bb07:: with SMTP id y7mr996771ede.358.1588922996049; Fri, 08 May 2020 00:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588922996; cv=none; d=google.com; s=arc-20160816; b=lMhRhanYWpVWFVGdDyHmUP+VSdY3L2+gcKz845MI3egkRpGgWpqTYJ0DW8w6O77Nzz QB9W+iKJWgYmg5U2frlT+8P5MdtpXYHa+VGgEU2IjmE3B3cmK7AlWXE1oEgPmgIMsYPS o/DS/IeIWvIP1XVD9Skdq9YCr5I/0B1PHTogD5X34ITiw0KSwX67E/Ja7P73PWJ1wS19 ki7I2j8w7aBzziM6JAd4u3rrKPDLEfV/i5HX9avkEiPjVZIkDIYUeBKysTn4el3QJ6sI pamCv1THANastgPTXP+2kP4potN5SBQHqyRiWkORlYLuyiC0EB8uX7hCXVTxlrYqUJh8 rmmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=FGRf5btWDNQ4nRxUHPVdOveD+xh7SL2Jo+WdiT4LMG4=; b=FKRZbqk0I+4OSnlVvkiMcUVH9nh87HwF/9H4zA103PZtOAeE57KVkR74e4hg6u0pES wQ+EpSmOnxAg+9MHu1I15GSWyqEO470QaOdZNyvVWEZ3QWcLf78DdXTXB+9l62sOfBw2 mQ1v1+S9b1dgQPZoA/SDo52AqWLH627Q4ZKd8MPTrvjv9/4CHSu23/Eda0/4Ym1IV3h0 7TFcuq6GAgeg1Vh+1V1BhWEwCJl3dBOITKwVm+zmS+8V7fM+IFSw9PVJm2PEs/kDbj74 MTAZTvl6cQWtsY/AeeXtExM2m5fPv01c0g/mPciwah3HTF/O/tDopssFzN3PgyEnC0ax DS7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si483921edr.351.2020.05.08.00.29.33; Fri, 08 May 2020 00:29:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbgEHHZX (ORCPT + 99 others); Fri, 8 May 2020 03:25:23 -0400 Received: from mga18.intel.com ([134.134.136.126]:27650 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbgEHHZW (ORCPT ); Fri, 8 May 2020 03:25:22 -0400 IronPort-SDR: OJYSn+/+lIb7j86ASAD0ZRVs8yfORZvdfzS9XbrvUbWOY6lAl+JkTFop7QBBo/EK9O5z1S2d3D EHsKM6ndFnCg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2020 00:25:22 -0700 IronPort-SDR: 1UP0CFtipWjgq6gQJZBzzZajBTmR3A4NjdCKdgyxGhXkDCpDK7ixJn3UVKURlKus5kQgvXntPF hyx/BhGficZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="264210525" Received: from shbuild999.sh.intel.com ([10.239.147.136]) by orsmga006.jf.intel.com with ESMTP; 08 May 2020 00:25:18 -0700 From: Feng Tang To: Andrew Morton , Michal Hocko , Johannes Weiner , Matthew Wilcox , Mel Gorman , Kees Cook , Luis Chamberlain , Iurii Zaikin , andi.kleen@intel.com, tim.c.chen@intel.com, dave.hansen@intel.com, ying.huang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Feng Tang Subject: [PATCH 0/3] make vm_committed_as_batch aware of vm overcommit policy Date: Fri, 8 May 2020 15:25:14 +0800 Message-Id: <1588922717-63697-1-git-send-email-feng.tang@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When checking a performance change for will-it-scale scalability mmap test [1], we found very high lock contention for spinlock of percpu counter 'vm_committed_as': 94.14% 0.35% [kernel.kallsyms] [k] _raw_spin_lock_irqsave 48.21% _raw_spin_lock_irqsave;percpu_counter_add_batch;__vm_enough_memory;mmap_region;do_mmap; 45.91% _raw_spin_lock_irqsave;percpu_counter_add_batch;__do_munmap; Actually this heavy lock contention is not always necessary. The 'vm_committed_as' needs to be very precise when the strict OVERCOMMIT_NEVER policy is set, which requires a rather small batch number for the percpu counter. So lift the batch number to 16X for OVERCOMMIT_ALWAYS and OVERCOMMIT_GUESS policies, and add a sysctl handler to adjust it when the policy is reconfigured. Benchmark with the same testcase in [1] shows 53% improvement on a 8C/16T desktop, and 2097%(20X) on a 4S/72C/144T server. And no change for some platforms, due to the test mmap size of the case is bigger than the batch number computed, though the patch will help mmap/munmap generally. [1] https://lkml.org/lkml/2020/3/5/57 There are some style complain from checkpatch for patch 3, as it follows the similar format of sibling functions patch1: a cleanup for /proc/meminfo patch2: a preparation patch which also improve the accuracy of vm_memory_committed patch3: the main change Please help to review, thanks! - Feng ---------------------------------------------------------------- Changelog: v2: * add the sysctl handler to cover runtime overcommit policy change, as suggested by Andres Morton * address the accuracy concern of vm_memory_committed() from Andi Kleen Feng Tang (3): proc/meminfo: avoid open coded reading of vm_committed_as mm/util.c: make vm_memory_committed() more accurate mm: adjust vm_committed_as_batch according to vm overcommit policy fs/proc/meminfo.c | 2 +- include/linux/mm.h | 2 ++ include/linux/mman.h | 4 ++++ kernel/sysctl.c | 2 +- mm/mm_init.c | 19 +++++++++++++++---- mm/util.c | 15 ++++++++++++++- 6 files changed, 37 insertions(+), 7 deletions(-) -- 2.7.4