From patchwork Mon Apr 17 07:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 13213417 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 A8172C77B72 for ; Mon, 17 Apr 2023 07:55:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 398518E0002; Mon, 17 Apr 2023 03:55:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 349598E0001; Mon, 17 Apr 2023 03:55:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 211848E0002; Mon, 17 Apr 2023 03:55:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0E4838E0001 for ; Mon, 17 Apr 2023 03:55:09 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D66EEC049F for ; Mon, 17 Apr 2023 07:55:08 +0000 (UTC) X-FDA: 80690122296.24.7D5AE73 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf03.hostedemail.com (Postfix) with ESMTP id 1C9FC20003 for ; Mon, 17 Apr 2023 07:55:04 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=FLifemwV; spf=pass (imf03.hostedemail.com: domain of fengwei.yin@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681718106; 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=xskInVOjlteN7VowAD0IajGNRg7KFVb8ujABQE52+4U=; b=MX4B1B33LRzGGjR6UBLamxJBhSi70T7Fap0NA348r+aBx6isAFh/yV8jkc3scXnrlwvCIP ETJRWnSyxYl1keSh82fOK44vEKnlROW0NPg0p/F9lysPMRsTex8CrV4ZsALpkGXBi8EFQ1 1/iMYJaqif8Uyu1SQtHtJyXPfT9tbrM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=FLifemwV; spf=pass (imf03.hostedemail.com: domain of fengwei.yin@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681718106; a=rsa-sha256; cv=none; b=CN1XrbcrYNmRP9Wuf8/8QQuMDNAu/7c7NplYCuiCZoMLjb4G754QH36baRc5FZYyTBwxxL A+4/h7lOM+JJq4yl/qDGRB9rU3qPoZHMZ2d5tpxFpdimvNNDVeA0K1KLQkKh7GTfIX96ms XeYrtgfcTCSg653MSqLg/97HVnaj0b0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681718105; x=1713254105; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=R1LzGfwLQdzAPmpqviE4WOCJSrMMQHetrs8Wq25wB0M=; b=FLifemwVuWUV7yTGU/mgvOTYKnLpWWD7dWr5mLgO51dKy0tI7Vft0AlS gAIQ1k701djrTCgqNoR2uzmWSK4Rh5i6GDuMZg0eGYWnqVAIGg31wMFx1 3iw7v/uN0hBRK+LlWSDLAsGCDRHhbrZWLFq3PBpQVPceklRhlBaMDPj82 iLPUMSOnhaTun3D9KfOjsbQ+zyfbcMnGQni2KF0KcIqQHuTT1PgXa9UpN 28oeXoDWaQ5/pN7S/RZDRhaXZ66G7r2yOB6q2eGSSRPzFYsIcLUSs94Jm glVKOZMnp5K9rZid2qTaf4LS3KFuZB+ea8dppSmVNTxNZBSfVP/TLo1UV g==; X-IronPort-AV: E=McAfee;i="6600,9927,10682"; a="324453761" X-IronPort-AV: E=Sophos;i="5.99,203,1677571200"; d="scan'208";a="324453761" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 00:55:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10682"; a="723167403" X-IronPort-AV: E=Sophos;i="5.99,203,1677571200"; d="scan'208";a="723167403" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by orsmga001.jf.intel.com with ESMTP; 17 Apr 2023 00:55:01 -0700 From: Yin Fengwei To: linux-mm@kvack.org, akpm@linux-foundation.org, willy@infradead.org, yuzhao@google.com, ryan.roberts@arm.com Cc: fengwei.yin@intel.com Subject: [PATCH 0/2] Reduce lock contention related with large folio Date: Mon, 17 Apr 2023 15:56:41 +0800 Message-Id: <20230417075643.3287513-1-fengwei.yin@intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1C9FC20003 X-Stat-Signature: hxx3i5txt4dank669s6b6snjd51mskbu X-Rspam-User: X-HE-Tag: 1681718104-138396 X-HE-Meta: U2FsdGVkX18tY8W0tRpkvfEtmq1S1CXyxV0p84TK7l/XNUdKheJ44O/KbRWqMDpxlr+Z5wD+48eUUJBEJVn7Mqfcwo/Ob8fjPLh4zTepKF+Kwc6PBp0JJ9gC8lKxSxyYKYWmvxgf8OO38UxTE64Pl5hnGPWqplYW23N4dZh4SXPa5hBxhEqIkk17hFmg4ToAsYQ99g9yHXo3SFCPoPjyaxThdbnkHqSuIqSiY4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4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Ryan tried to enable the large folio for anonymous mapping [1]. Unlike large folio for page cache which doesn't trigger frequent page allocation/free, large folio for anonymous mapping is allocated/freeed more frequently. So large folio for anonymous mapping exposes some lock contention. Ryan mentioned the deferred queue lock in [1]. We also met other two lock contention: lru lock and zone lock. This series tries to mitigate the deferred queue lock and reduce lru lock in some level. The patch1 tries to reduce deferred queue lock by not acquiring queue lock when check whether the folio is in deferred list or not. Test page fault1 of will-it-scale showed 60% deferred queue lock contention reduction. The patch2 tries to reduce lru lock by allowing batched add large folio to lru list. Test page fault1 of will-it-scale showed 20% lru lock contention reduction. The zone lock contention happens on large folio free path and related with commit f26b3fa04611 "mm/page_alloc: limit number of high-order pages on PCP during bulk free" and will not be address by this series. [1] https://lore.kernel.org/linux-mm/20230414130303.2345383-1-ryan.roberts@arm.com/ Yin Fengwei (2): THP: avoid lock when check whether THP is in deferred list lru: allow large batched add large folio to lru list include/linux/pagevec.h | 19 +++++++++++++++++-- mm/huge_memory.c | 19 ++++++++++++++++--- mm/swap.c | 3 +-- 3 files changed, 34 insertions(+), 7 deletions(-) Tested-by: Ryan Roberts