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 ED587C77B73 for ; Mon, 17 Apr 2023 01:15:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EC898E0002; Sun, 16 Apr 2023 21:15:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69B998E0001; Sun, 16 Apr 2023 21:15:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5645D8E0002; Sun, 16 Apr 2023 21:15:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 428C28E0001 for ; Sun, 16 Apr 2023 21:15:54 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 168A7AB765 for ; Mon, 17 Apr 2023 01:15:54 +0000 (UTC) X-FDA: 80689116228.24.9154506 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf26.hostedemail.com (Postfix) with ESMTP id 028BD14000C for ; Mon, 17 Apr 2023 01:15:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=CMhfN50g; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf26.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681694152; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VwkDcSPMQqnvXz89Rwd5EfEI+0smOZjOdK7Dwdqjuss=; b=vnek2rd0l3bgf/PRQbBorD7+pKMHRF481PF1Shds+fS0Dh/AJ3kIfE02CsOyl8T+vmfvzo rRE8rJbEYfNkQW/09fFbS7hFrz+keI4gXSW5eXj97aveK1uDkPyuY4dZAHK1d3aq5UxKCN IpgPS0ZCFnCF5wGSvXOgHAXQ/jxH/4k= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=CMhfN50g; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf26.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681694152; a=rsa-sha256; cv=none; b=Nl0/IGiJnhiHhsPE/EZXUwhlytf93NqipwTqcYS5VM1ZNw1WmDHfR6EBxDePVTTDhz7uAZ 2JzaittbQOoeMpLgRtYMMOX/aV2Ohk5WvLHBJ7VQEJgL4B0QYsPToc9+fODITB9579ZWyN K59VycsPa0gQXc/nZeIgmQXnCqTxmNk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681694152; x=1713230152; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version:content-transfer-encoding; bh=IJ6evs6TW37+brfn0Z0UYuw5IHHOBHHjxO0DDMC2qdI=; b=CMhfN50gPt2n34kGIy83I7C/1wrQeUwgjMotaIojaBbZstduJtvhrfAl NIziNAEGyixIuusNQXN1uJ9rprmI/4y0zQZpo2fDuyKkZNvQHCFUvBgvi CZqG/8JZ+s830B57AP6/sdAEMnDoWYpQnan3UgKqDR9cIU9lhKYGCmlIN wRC3Tl+b/2ohY1Dfv0g8Z5qE74w/riyFWdj+mxUaoVGdcCwtriN++H8Wk EYvId7p0/xjpZANkS8sVVBPWZd0Ds/dZhnmxl1LOvNwo5ieVR6jk9xYIV TdmhCYiHHWuSMF4xjpmQ+BVhXt179wqVUsWL0PP3ZTH8ylG5aJH+4PVjK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10682"; a="431069565" X-IronPort-AV: E=Sophos;i="5.99,203,1677571200"; d="scan'208";a="431069565" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2023 18:15:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10682"; a="814601989" X-IronPort-AV: E=Sophos;i="5.99,203,1677571200"; d="scan'208";a="814601989" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2023 18:15:48 -0700 From: "Huang, Ying" To: Doug Anderson Cc: Andrew Morton , Yu Zhao , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH] migrate_pages: Never block waiting for the page lock References: <20230413182313.RFC.1.Ia86ccac02a303154a0b8bc60567e7a95d34c96d3@changeid> <87v8hz17o9.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Mon, 17 Apr 2023 09:14:38 +0800 In-Reply-To: (Doug Anderson's message of "Fri, 14 Apr 2023 08:25:49 -0700") Message-ID: <87ildvwbr5.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=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 028BD14000C X-Stat-Signature: 4iuhpu18jiz9sc5mdj9cs5fudfiagsdy X-HE-Tag: 1681694151-276071 X-HE-Meta: U2FsdGVkX19IO/OalwU78hYaj0a6ZR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XTq8cTOE+JyN0cez9n5E2JZogw0eUTuoe1xBEwgL4M/V3iozLW+tmSFchdsSa9Y8Ao6x0QeEj/EDfsIW+/9+0h9ZBiLx5nXVKS6tS6/j3saEwXD5S4KmBAGqAX/RiDkDdecxh0mPLrsUocR6ah0t19uhtqC X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Doug Anderson writes: > Hi, > > On Thu, Apr 13, 2023 at 8:10=E2=80=AFPM Huang, Ying wrote: >> >> Douglas Anderson writes: >> >> > Currently when we try to do page migration and we're in "synchronous" >> > mode (and not doing direct compaction) then we'll wait an infinite >> > amount of time for a page lock. This does not appear to be a great >> > idea. >> > >> > One issue can be seen when I put a device under extreme memory >> > pressure. I took a sc7180-trogdor Chromebook (4GB RAM, 8GB zram >> > swap). I ran the browser along with Android (which runs from a >> > loopback mounted 128K block-size squashfs "disk"). I then manually ran >> > the mmm_donut memory pressure tool [1]. The system is completely >> > unusable both with and without this patch since there are 8 processes >> > completely thrashing memory, but it was still interesting to look at >> > how migration was behaving. I put some timing code in and I could see >> > that we sometimes waited over 25 seconds (in the context of >> > kcompactd0) for a page lock to become available. Although the 25 >> > seconds was the high mark, it was easy to see tens, hundreds, or >> > thousands of milliseconds spent waiting on the lock. >> > >> > Instead of waiting, if I bailed out right away (as this patch does), I >> > could see kcompactd0 move forward to successfully to migrate other >> > pages instead. This seems like a better use of kcompactd's time. >> > >> > Thus, even though this didn't make the system any more usable in my >> > absurd test case, it still seemed to make migration behave better and >> > that feels like a win. It also makes the code simpler since we have >> > one fewer special case. >> >> TBH, the test case is too extreme for me. > > That's fair. That being said, I guess the point I was trying to make > is that waiting for this lock could take an unbounded amount of time. > Other parts of the system sometimes hold a page lock and then do a > blocking operation. At least in the case of kcompactd there are better > uses of its time than waiting for any given page. > >> And, we have multiple "sync" mode to deal with latency requirement, for >> example, we use MIGRATE_SYNC_LIGHT for compaction to avoid too long >> latency. If you have latency requirement for some users, you may >> consider to add new "sync" mode. > > Sure. kcompactd_do_work() is currently using MIGRATE_SYNC_LIGHT. I > guess my first thought would be to avoid adding a new mode and make > MIGRATE_SYNC_LIGHT not block here. Then anyone that truly needs to > wait for all the pages to be migrated can use the heavier sync modes. > It seems to me like the current users of MIGRATE_SYNC_LIGHT would not > want to block for an unbounded amount of time here. What do you think? It appears that you can just use MIGRATE_ASYNC if you think the correct behavior is "NOT block at all". I found that there are more fine-grained controls on this in compaction code, please take a look at "enum compact_priority" and its comments. Best Regards, Huang, Ying