From mboxrd@z Thu Jan 1 00:00:00 1970 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 AA57AC61D97 for ; Mon, 30 Jan 2023 00:27:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BEFE6B0072; Sun, 29 Jan 2023 19:27:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 96F086B0073; Sun, 29 Jan 2023 19:27:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 836108E0001; Sun, 29 Jan 2023 19:27:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 706F06B0072 for ; Sun, 29 Jan 2023 19:27:47 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 30F5A4081E for ; Mon, 30 Jan 2023 00:27:47 +0000 (UTC) X-FDA: 80409577374.09.FB4D06D Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf17.hostedemail.com (Postfix) with ESMTP id 8FA1440007 for ; Mon, 30 Jan 2023 00:27:42 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ffpWcscS; spf=pass (imf17.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@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=1675038464; 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:in-reply-to:references:references:dkim-signature; bh=fuyFMrNfu3svcW8mIrLv/T4oExnor9lx8nU6yjGLkRo=; b=GUWqe8WOqdJuob0j0draZhQ8ua8ddEYxrCwLQDdkNJROAnik77+29QtA/5yp3XuwizdDrZ 41z4wXo2QeIh7jd7lReGayrTVvdYN4sAjDr4/ivGC+CJRLF1o3+XL7CAOTZdmhjQoAfXXp rhsFONW0S+GPQA5iBkEU+5tiMPYxQ0o= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ffpWcscS; spf=pass (imf17.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675038464; a=rsa-sha256; cv=none; b=XJWxEn4jyp2VgG+t7d2aJp7IAXr4+VO6QYe/s/mlVGYNq8L0xU9cPtF+NRdY7tSIXgszVO tY2TW1Ud3ksdGVzFw2Ouhx+/7U0lzIISZLignqlBzbaYxm1LmXQugGmxVzO17bSMxHNVC+ dYg1GNPBpnvkXZdeTu+00oCZ8ex5of4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675038462; x=1706574462; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=KzFBc20kahb9wi4J9Tti65MZDEEv3GXOS2/dFTGZ8tc=; b=ffpWcscSUU1ujZjgPKzhAXV2j4oyNAMsf4V7gYGhJEOcnOCps2OMxRxZ 7+l32dxJD3IK2KkuStzqi655kY0mL8LGDgMemRjsJpFrJjHvgUPXttlqX QLTRlOyCgrgOP8x7h5uDZhIqncu73/+Fr/eNi9MfWpmjTiPQD2WgFYKT3 At0ZnlNZwnbg2WGo/kMDO+R8FeStVNyfqu2A5YWSxTq7aRidhtVd6h0pv n8syotUJ7eGa0niZKpgb8Jbo7H3FyWFPEOd0qTQOig+ZRPmCRSMPwolwe vlOq7MX0DpmphKxkfQ8chMglu4+8ooaMwnY4UfiV9YEXfFwhG70X/v8Kq A==; X-IronPort-AV: E=McAfee;i="6500,9779,10605"; a="392005391" X-IronPort-AV: E=Sophos;i="5.97,256,1669104000"; d="scan'208";a="392005391" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2023 16:27:40 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10605"; a="663915024" X-IronPort-AV: E=Sophos;i="5.97,256,1669104000"; d="scan'208";a="663915024" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2023 16:27:38 -0800 From: "Huang, Ying" To: Andrew Morton Cc: Longlong Xia , , , , , Subject: Re: [PATCH] mm/swapfile: add cond_resched() in get_swap_pages() References: <20230128094757.1060525-1-xialonglong1@huawei.com> <20230129130320.7e2e4445ecc4b172c61c7b9c@linux-foundation.org> Date: Mon, 30 Jan 2023 08:26:41 +0800 In-Reply-To: <20230129130320.7e2e4445ecc4b172c61c7b9c@linux-foundation.org> (Andrew Morton's message of "Sun, 29 Jan 2023 13:03:20 -0800") Message-ID: <87wn54c1fi.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8FA1440007 X-Stat-Signature: iyzuru5w9mpdfexu5yd1jrjdcnnitxer X-HE-Tag: 1675038462-825972 X-HE-Meta: U2FsdGVkX1/waNgmQb84DNLognw0IVGhb5h8cheTUjcHP5ITTxW5tX9rpW8f5KM5PkdpV0yq0gT1v3JGSWeW6ayIcD4lPywhKch0VbFo+K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x0HmPntGJknAOXuVe+OinlxJCN6j/WRqTcBufgpVzv8rk+H5eZ0FBsrnWIFAzFLR/SzbELeZ0f+y83vqzyLjS+GAidcEhybCAgIGWd4pZ89ZA= 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: Andrew Morton writes: > On Sat, 28 Jan 2023 09:47:57 +0000 Longlong Xia wrote: > >> The softlockup still occurs in get_swap_pages() under memory pressure. >> 64 CPU cores, 64GB memory, and 28 zram devices, the disksize of each >> zram device is 50MB with same priority as si. Use the stress-ng tool >> to increase memory pressure, causing the system to oom frequently. >> >> The plist_for_each_entry_safe() loops in get_swap_pages() could reach >> tens of thousands of times to find available space (extreme case: >> cond_resched() is not called in scan_swap_map_slots()). Let's add >> cond_resched() into get_swap_pages() when failed to find available >> space to avoid softlockup. >> >> ... >> >> --- a/mm/swapfile.c >> +++ b/mm/swapfile.c >> @@ -1100,6 +1100,7 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_size) >> goto check_out; >> pr_debug("scan_swap_map of si %d failed to find offset\n", >> si->type); >> + cond_resched(); >> >> spin_lock(&swap_avail_lock); >> nextsi: > > This must be pretty rare? My googling for "scan_swap_map of si %d > failed to find offset" turns up zero reports, but I guess few people > enable pr_debug. > > I wonder if we should remove that pr_debug(). I mean, it's known that > this happens, what value does the printk add? Sounds reasonable to me. And if we want to debug, we can use bpf too. > I'm thinking this fix should be backported into -stable kernels. Best Regards, Huang, Ying