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 3C0DFC77B72 for ; Fri, 14 Apr 2023 15:26:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D63D06B0072; Fri, 14 Apr 2023 11:26:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CECEC900003; Fri, 14 Apr 2023 11:26:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8D28900002; Fri, 14 Apr 2023 11:26:07 -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 9B9636B0072 for ; Fri, 14 Apr 2023 11:26:07 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6C3A112034E for ; Fri, 14 Apr 2023 15:26:07 +0000 (UTC) X-FDA: 80680372374.20.B3030C7 Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by imf03.hostedemail.com (Postfix) with ESMTP id 7833F2000C for ; Fri, 14 Apr 2023 15:26:05 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=QH1FqJeF; spf=pass (imf03.hostedemail.com: domain of dianders@chromium.org designates 209.85.166.169 as permitted sender) smtp.mailfrom=dianders@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681485965; 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=gVIzYueR5h3salqus+tvLerctScXZDI3PZY9MNj+cH4=; b=2HJGct9s52+1+b4OR/W+os+BEDdCUx5QIbqYkMzdXL3uJLA7SaQzWJU7nFrxHzBgpvBsWg IbDne14DnSuwxGU8lO2L+CQDGoYXC4UgmiM8BhTOvtjA/r4s+2KqJMlutVb7FQcUgAO4n+ l0a+zRaU9vn76fkdeMIPIvyyxt/9pHg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=QH1FqJeF; spf=pass (imf03.hostedemail.com: domain of dianders@chromium.org designates 209.85.166.169 as permitted sender) smtp.mailfrom=dianders@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681485965; a=rsa-sha256; cv=none; b=y05P3VlRcB0Egy7MZQZZaJykYbCLMnsRr0XDpfMojK6xFA4N/1DTyKzqPXKfQqYzgnmTp3 f3XwKYzPSeONxnS/kqpVk/Zqb1qreZx+9vYQTLFahbGzO7U+35kMm1G1KGHl+NLBXtWMfq e5UU/VtMGg4mvYap+sn7taDBCCQvEi0= Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-3282e8beea3so8530575ab.1 for ; Fri, 14 Apr 2023 08:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681485963; x=1684077963; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gVIzYueR5h3salqus+tvLerctScXZDI3PZY9MNj+cH4=; b=QH1FqJeFAK+xWXX+XVJrVvdWSs8j2coXbS9fVJT/mPQBC6Yr5lxCWi2p0probPiGRp YQnkoKTj9yFKgE7TqHNtGf4oK3Ft3QeDaLj6Hqrgo9PPSpiJNH1EyqPtrEKK/bFOtneV zhVRx5EGRbXD9FZr+zSDV5ZVdpIhSAqJiRfr0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681485963; x=1684077963; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gVIzYueR5h3salqus+tvLerctScXZDI3PZY9MNj+cH4=; b=DSIjZ+pRbcaZVZSwUfGQL0t8tgIzQGx8+KRwvgp+cm+0gEgDinfvaQXstmEAcA6bIB amT/iXzDeZ27GGmZDIX2JRg6g0CYS7DbBYnlSEtOEci4M8LN3efuOjb/I0C47hC1zPTI ipL0/W21aFfKFDvQ/xA/PLDpb9qNmQQLU/J61vizaNmpME5zV/or7q16xb26xq6H987a fVBfyRQNn0ZV7VrZ9x2+30cLkM88rRB8ef4rCx+j+l0BE+S5tpTIRcYyzzxKjXH2CTbO TV9gWLeQ8/eiVMAuf7uplhLYj/IjqFsx1OKxkqU+4fozSD/uPPHVaOqLiUKeaMQZiaLi kxBA== X-Gm-Message-State: AAQBX9dFyzuClzjhNlJP+G7TK1pokXM9mENkGdBtxgGFlpqjMETCUsva 9dXhugxIi9XUhLyDCHhWpOlPyPME5CMM38i6KEQ= X-Google-Smtp-Source: AKy350YJ7un7QR499/k//iPpTP90sfS2zGUT8NAX6bjrHq0sHSShQ9+oMUpgKrhCe3ajNyNgq4D9lQ== X-Received: by 2002:a92:d403:0:b0:326:2b56:3cf5 with SMTP id q3-20020a92d403000000b003262b563cf5mr3793361ilm.22.1681485963263; Fri, 14 Apr 2023 08:26:03 -0700 (PDT) Received: from mail-io1-f43.google.com (mail-io1-f43.google.com. [209.85.166.43]) by smtp.gmail.com with ESMTPSA id s10-20020a92c5ca000000b003288083182csm1212971ilt.17.2023.04.14.08.26.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Apr 2023 08:26:02 -0700 (PDT) Received: by mail-io1-f43.google.com with SMTP id c10so3513855iob.9 for ; Fri, 14 Apr 2023 08:26:02 -0700 (PDT) X-Received: by 2002:a6b:e80f:0:b0:74f:d943:f1cf with SMTP id f15-20020a6be80f000000b0074fd943f1cfmr2300579ioh.3.1681485961798; Fri, 14 Apr 2023 08:26:01 -0700 (PDT) MIME-Version: 1.0 References: <20230413182313.RFC.1.Ia86ccac02a303154a0b8bc60567e7a95d34c96d3@changeid> <87v8hz17o9.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: <87v8hz17o9.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Doug Anderson Date: Fri, 14 Apr 2023 08:25:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] migrate_pages: Never block waiting for the page lock To: "Huang, Ying" Cc: Andrew Morton , Yu Zhao , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7833F2000C X-Rspam-User: X-Stat-Signature: 9yez19pupnq3aqsmxhptke8xxuu4gosm X-HE-Tag: 1681485965-973097 X-HE-Meta: U2FsdGVkX18ip/kfDM4LECiHkOTDm+fCFLUT+uY3pDNwa6doplLJGfdLBTSHv4vWYUTDorG/f//Yo5YYRpiLE88xWdLa4dq3YkT08ICRt7FcEbg2oTW3kEnZZeq8Ju8fGCjKStVK1he9L+McpmlZ0OfFMJJleE7v2ZdOpEvzr9ILojPudrHupv1/FdnBrRPIZsDI/mtpBNH7Z7bzCVwy7/OLB8B46cIutpiH5HIpZQDBTq5RAkXYq5yeMp8avH8y02WZPHJFePqz6Y3ki/MkqldXyyWTft6AsVA8HfW7e+8TGj309HsJTbKKnqOmWtHHkV3hxbaEed64HY0tjlufY1jTQaJ7tW7U2TM4aePF6MEkoi+/s8mYhkqyaIj6cz2crsHbzGgn3BC/Ts38SESqIE89zlvpMOKXkYuU5sj5wy15ZHWXXTd7xN1uAlS7wCBCLhxBBcTuLhtus7AqE+55tlwJsDBlPX+V1y7XCajtoPQZEy3nz+BSBAl71QAA1AaidboOC9PpJS0HpAjRNRMBGPpxPmPQmZIUKOEyVJZf+Sf/UV+uxfv8hFbS7gmkDRr+WMHx+g0CTWUQ3jqOap5r4OBKuFOdzDJslthewiQdtfZTsqz8CDUjOGn3pDx+wlTa9rakqz8Xd/1wjvDMN6CIdRVIANU2euwo60rQrkCMhSkpQcXDrTxBuyOSN1dYqFSHz4Nl8y0JgJkJ7F6bSt8A/7jY9PF1m1TikgmjFq6/OWG12bpVvYHhRaZWKxHLakY1NvtkgmC6EYEo2+brhjj3STg2YKWsXpjIpAibLjGNW8BZiYqD+rLfyvBCU3WpiS/6jGey9mcOBNZZaxOPL1O3NKwdyftNzg2DY/IOPBRbV3sZ8HTIw1GkpcYlAUhnJ5253ITMwKVWgAj5EOcMCFoijmYzMddBYk3i8UCSQFBfFwKrYH9Wj7DVOK1aik516/0yCY4HEQWyejeQMzCM09+ 8SUvuzGT MYzDpHRBa+YOdbnraBMKlVCfvNKynD3JW6bX+rFWPXblyEDGXXqp82ffM0Ftwl7+TIk1MBCQrBkMU7qpNvFOCKQEVzTWJIK/K+h9qeHA5DJFnUARuanz214pEGvbQBKzlvMyS/dKValyh+95FO6QRRmL+x/Xge+xZ54cZBhIDdGZnIqACTWRAMV77FhDqLM5mJzDmxlaWYQ1HIIa5GaMV919yo70e0wBxdVtnLKrjJ+l9dGJGYxw16rQIQPrKiaZw4nBKh6/a2xHAy+g1wZYkNRdsP3nztV0+zzctlBFQsFWE8lW1OJKJZ+K/gK26ur3imH5qm1bjHsoSbzPBd3x2pLyp11PQPhSdTMrvHJaZ4pFe7vwgzYPOJyxhYzzakovQGR4cToPKEuWSx81nEZSbUrJ2KYo2CSrTyBveCzcD75bS5PO6/ux4Wakgx2WpYiIF7NCf X-Bogosity: Ham, tests=bogofilter, spamicity=0.000448, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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? -Doug