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 X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FSL_HELO_FAKE,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A668C10F14 for ; Thu, 10 Oct 2019 22:11:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CF76620B7C for ; Thu, 10 Oct 2019 22:11:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fVwJWfw/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF76620B7C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 347C98E0005; Thu, 10 Oct 2019 18:11:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F7938E0003; Thu, 10 Oct 2019 18:11:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E65C8E0005; Thu, 10 Oct 2019 18:11:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id EC7628E0003 for ; Thu, 10 Oct 2019 18:11:10 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 74D0182437C9 for ; Thu, 10 Oct 2019 22:11:10 +0000 (UTC) X-FDA: 76029271500.13.pets95_446129470f83a X-HE-Tag: pets95_446129470f83a X-Filterd-Recvd-Size: 6736 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 22:11:09 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id e1so4540405pgj.6 for ; Thu, 10 Oct 2019 15:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qADNUvS+wZZ6b+j5JoGWu2BAJFTWzwEv5YCmhezwwyw=; b=fVwJWfw/rBVm5lRe9ccZX00npdQe8P/eERP1qH9jIUfFRV9oW07CqNO0fDap1OVIoP WouVMv3TJTuIbIP9fmP6SwNo/gEEWkPQP/qNmJmIJc0tmWFzCLIS/yF5oB2fZcTzmvMo J3vi1oQT3dnPW73HGUIiwpMQJKZwEQ/I5UulEVNRWTj7qYuRFs6kO6Y660sUnVGPm+o+ bbl7OMCk8dWD0nHP/K9lhAoZzCTc7LlYLH+pUxYyFN3TRrGTZ2ZnQqDb8cJAplpF4kM6 v2b4EnNNO6cT/KkxagyotDRQ0SdJmJYxmMHKxN2MQuBNZGhvnmNxBKPx16jcYVxD7+Yr 1w7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=qADNUvS+wZZ6b+j5JoGWu2BAJFTWzwEv5YCmhezwwyw=; b=HCBdDtHaNBNVvJGxQJY4+VLghvE1BwjYLZowrJu3ChAdy7EQkJLEwFbgQwBBLki2yO dJvhjka89LnnWReqv5fe2Qc17Bz2jtwtz8S3KKbflMDCZm/RQ20MNsE7dYseZHM9Y5EG JHfiXgBWH+iMlgk1xBHVpEudxVL7ptIGWMo8UQqw3rEF1gecHKXWcw52PL8bMEb8Rf4v r4wCcIlxB+xghEwSpKGqtZkJY6xGO1dPn5QlKVojtDekctWi8pu/kjGRvb2Vgvd9wqiN rg3bpSL6A3Qt4D/s32/lkbUfjTBWWZhhNhPyI1T+7ZV6vM+pEuf9tkRzpV+KMQcyNsk4 Hp6Q== X-Gm-Message-State: APjAAAWz85EoV8Z0DIhASOpELj7nBLU2lsWp6ISA+DvACBcgsvfacIik jZr99XNTBXIJzWJTJ6bgCFw= X-Google-Smtp-Source: APXvYqzop87ZTzzB99HjTwcbSSciQldMFCBfalaSatXuR5YGQPv2TAzUEKonTsc4F+9asgcVJLdhDQ== X-Received: by 2002:a65:4bc2:: with SMTP id p2mr13345227pgr.177.1570745468371; Thu, 10 Oct 2019 15:11:08 -0700 (PDT) Received: from google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id f12sm5793353pgo.85.2019.10.10.15.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 15:11:06 -0700 (PDT) Date: Thu, 10 Oct 2019 15:11:05 -0700 From: Minchan Kim To: Johannes Weiner Cc: Andrew Morton , linux-mm , LKML , Sahkeel Butt Subject: Re: [PATCH] mm: annotate refault stalls from swap_readpage Message-ID: <20191010221105.GA115307@google.com> References: <20191010152134.38545-1-minchan@kernel.org> <20191010191747.GA31673@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191010191747.GA31673@cmpxchg.org> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Thu, Oct 10, 2019 at 03:17:47PM -0400, Johannes Weiner wrote: > On Thu, Oct 10, 2019 at 08:21:34AM -0700, Minchan Kim wrote: > > From: Minchan Kim > > > > If block device supports rw_page operation, it doesn't submit bio > > so annotation in submit_bio for refault stall doesn't work. > > It happens with zram in android, especially swap read path which > > could consume CPU cycle for decompress. It is also a problem for > > zswap which uses frontswap. > > > > Annotate swap_readpage() to account the synchronous IO overhead > > to prevent underreport memory pressure. > > > > Cc: Johannes Weiner > > Signed-off-by: Minchan Kim > > Acked-by: Johannes Weiner Thanks, Johannes! > > Can you please add a comment to the caller? Lifted from submit_bio(): Sure, I added a little about zram. > > /* > * Count submission time as memory stall. When the device is > * congested, or the submitting cgroup IO-throttled, > * submission can be a significant part of overall IO time. > */ >From a8ae7cbc2d3f050aca810fd68285d45cb933b825 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Thu, 10 Oct 2019 08:09:06 -0700 Subject: [PATCH v2] mm: annotate refault stalls from swap_readpage If block device supports rw_page operation, it doesn't submit bio so annotation in submit_bio for refault stall doesn't work. It happens with zram in android, especially swap read path which could consume CPU cycle for decompress. It is also a problem for zswap which uses frontswap. Annotate swap_readpage() to account the synchronous IO overhead to prevent underreport memory pressure. Acked-by: Johannes Weiner Signed-off-by: Minchan Kim --- mm/page_io.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 24ee600f9131..18f1f8e1d27f 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -354,10 +355,20 @@ int swap_readpage(struct page *page, bool synchronous) struct swap_info_struct *sis = page_swap_info(page); blk_qc_t qc; struct gendisk *disk; + unsigned long pflags; VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageUptodate(page), page); + + /* + * Count submission time as memory stall. When the device is + * congested, the submitting cgroup IO-throttled, or backing + * device works synchronously(e.g., zram), submission can be + * a significant part of overall IO time. + */ + psi_memstall_enter(&pflags); + if (frontswap_load(page) == 0) { SetPageUptodate(page); unlock_page(page); @@ -371,7 +382,7 @@ int swap_readpage(struct page *page, bool synchronous) ret = mapping->a_ops->readpage(swap_file, page); if (!ret) count_vm_event(PSWPIN); - return ret; + goto out; } ret = bdev_read_page(sis->bdev, swap_page_sector(page), page); @@ -382,7 +393,7 @@ int swap_readpage(struct page *page, bool synchronous) } count_vm_event(PSWPIN); - return 0; + goto out; } ret = 0; @@ -418,6 +429,7 @@ int swap_readpage(struct page *page, bool synchronous) bio_put(bio); out: + psi_memstall_leave(&pflags); return ret; } -- 2.23.0.581.g78d2f28ef7-goog