From patchwork Thu Oct 10 15:21:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11183817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 51CD1112B for ; Thu, 10 Oct 2019 15:21:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1EEBE214E0 for ; Thu, 10 Oct 2019 15:21:43 +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="uplxbTeu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EEBE214E0 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 478DA8E0003; Thu, 10 Oct 2019 11:21:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 42A3E6B0006; Thu, 10 Oct 2019 11:21:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3188B8E0003; Thu, 10 Oct 2019 11:21:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 0B6E46B0005 for ; Thu, 10 Oct 2019 11:21:42 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 9C48634A1 for ; Thu, 10 Oct 2019 15:21:41 +0000 (UTC) X-FDA: 76028239602.24.veil97_8323712de0042 X-Spam-Summary: 2,0,0,d1d0655fe100897a,d41d8cd98f00b204,minchan.kim@gmail.com,:akpm@linux-foundation.org::linux-kernel@vger.kernel.org:shakeelb@google.com:minchan@google.com:hannes@cmpxchg.org,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1431:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2890:3138:3139:3140:3141:3142:3353:3865:3867:3870:3871:3872:4042:4250:4321:5007:6261:6653:7576:8957:10004:11026:11473:11658:11914:12043:12296:12297:12517:12519:12555:12679:12895:12986:13894:14096:14181:14394:14721:21080:21444:21450:21451:21627:21740:30001:30054:30070,0,RBL:209.85.215.194:@gmail.com:.lbl8.mailshell.net-62.18.175.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:31,LUA_SUMMARY:none X-HE-Tag: veil97_8323712de0042 X-Filterd-Recvd-Size: 5008 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 15:21:40 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id p30so3894358pgl.2 for ; Thu, 10 Oct 2019 08:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GJ0bdDzYh0lxFK9AeeKMP0j0WGOxu0ifEP2yMEIR13Q=; b=uplxbTeuvNXnuCU8R/Ocyq1MEfTaAw4hd9XM4pYTzr2xPjME6dZy5IS7xWFPtYcPeS 2PzzqS1XBNyvOxgeG8XoZxGupCW4ml0D70Aj/Tftmehzz7c2RedhUcryHqXU2ZkG7+CF 5x4wv2MQW4Z5CmpsztgpwO7a7mxGKYEfluVi6kJN5v8xz9xvnXAEbVUVHF/MXxL/4b0P a+frqmj9pdfXgr9nA2ieosL5pN3Xzl4jEDYCJy7Rlc5f62T6qRlNxFNbyWpetQH66leg QCSaRYFGH3LgLp94xuLNw7TLHwS2li4y2R/VDe6XSt8PuQ5o2TQ3xMl0muPKE6tMC37E 9arQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=GJ0bdDzYh0lxFK9AeeKMP0j0WGOxu0ifEP2yMEIR13Q=; b=qZHTPckg8t8u4a9rdaPqTSgGjz6HnkNcA7Wt9WWjPpZfhlejvdpw5SpldB215GQOhX hAj02BGGjFXLHr1bApJdJrVwPHjwfsmaX/L9I7p7Rt0zs6V77489Ls7i2lR/H9+ke5iO PgUb5ehfrumMNM+dXODFI3mta0NL/ZCoEirPGdl32GEdBnpyMouV+TOyIiebA1G8S0wi HiBNJ3CP6Ea5zf05/wd4Odd5c96vNp7OcgUnBvkwbBiMCQcSwMwUYk3PMi7HyPgSk2We BdbRkrMEXKA8QFbx3aHBqnLifZXI0NB8cjX/ox+ylo+jee7lSBpDmWpAuOslTIP7GiOr Ly9A== X-Gm-Message-State: APjAAAWVzL1NiXaA9PgUytRNreopV54HKE8QwRfE373f06R6M3BWIuCH 55f7W5uDKO0g4ZvIzegM3bc= X-Google-Smtp-Source: APXvYqx6ZefpzHnRz7hI7XMQ6e6TPPO/smbkd5wKvsUxVhoN8VrPkcXqCq3VJcCbEj9oRuuLBbkT0g== X-Received: by 2002:a63:6142:: with SMTP id v63mr11886432pgb.110.1570720898777; Thu, 10 Oct 2019 08:21:38 -0700 (PDT) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id d1sm6999772pfc.98.2019.10.10.08.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 08:21:37 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: linux-mm , LKML , Sahkeel Butt , Minchan Kim , Johannes Weiner Subject: [PATCH] mm: annotate refault stalls from swap_readpage Date: Thu, 10 Oct 2019 08:21:34 -0700 Message-Id: <20191010152134.38545-1-minchan@kernel.org> X-Mailer: git-send-email 2.23.0.581.g78d2f28ef7-goog MIME-Version: 1.0 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: 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 Acked-by: Johannes Weiner Signed-off-by: Minchan Kim Reviewed-by: Shakeel Butt --- mm/page_io.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 24ee600f9131..20147473d4a5 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,14 @@ 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); + + psi_memstall_enter(&pflags); + if (frontswap_load(page) == 0) { SetPageUptodate(page); unlock_page(page); @@ -371,7 +376,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 +387,7 @@ int swap_readpage(struct page *page, bool synchronous) } count_vm_event(PSWPIN); - return 0; + goto out; } ret = 0; @@ -418,6 +423,7 @@ int swap_readpage(struct page *page, bool synchronous) bio_put(bio); out: + psi_memstall_leave(&pflags); return ret; }