Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2508408ybp; Thu, 10 Oct 2019 08:22:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzO2unYBCu/0x33vskyo6Mm5ujELRCQLytzL2CkrP2RVximCHBPhd1m9H8fVgW1RrG0UisV X-Received: by 2002:aa7:c38e:: with SMTP id k14mr8765217edq.127.1570720965875; Thu, 10 Oct 2019 08:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570720965; cv=none; d=google.com; s=arc-20160816; b=FWxIhp17yDyikHxiNfhRlleMneykZ3mRm5hNQKbSbpHmMAx0Cb4MSc5YIUbWf76cDY BDZv3dMBW0jEzAmrkzV+20NZBxWdT3doXyf6X5SOQNs3vEYBjV4ILqkmmTdql3JcwVOC rTVM0MhSTYDBIH4qy12Yg/oyRd6R+oxuDFC/FKGG2jP0uPUXuhEv9xwAHRGPyuHOrScL ErpdTi3pM1jP6tsnA0KB9DyvbEP9ZWUm0Oa+snrZ2nRErrYnj5UdrEQfHr1zPg7haAgG s4bIrdezlvuO+cT6Wqu4VtjWB0Z/urkMMD4+YIQyL7W/oetjUOBTN9E0+Tv9Ysvjik2u 8btw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GJ0bdDzYh0lxFK9AeeKMP0j0WGOxu0ifEP2yMEIR13Q=; b=eQUJsKqko0Jhy/bwqPl40kh13bojvMWbZN2qKlWrs1VAmtJa8qvP8hF8QdzaDd9eVX HoZ3Zyq/GFgMaDTqVi/ZsSFYgwYkZdRFwmclntuluKkcsPART5WFNElk4TscVOrF8XX0 cipWSXH5Q3tGMI6LIaWe3RvpBFUpLPsX4V7XO+LE2/ZFdCoaR1mdRJFmWP9yvT0c+Oyg RWfjGsUCZBqYSDxRhBe7KSVfpuK2p0ycMUDiHUCCQ6JCiDT7QYyaP8OM1YL0LHTlCrio LovclMw6aIFr9snjQ3A1J3ogdQ7XSSuIRwczXaCCYVYHuvjTI/BLAObJ8trpBrm1mOEZ QUVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uplxbTeu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si3251726ejw.76.2019.10.10.08.22.18; Thu, 10 Oct 2019 08:22:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uplxbTeu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbfJJPVk (ORCPT + 99 others); Thu, 10 Oct 2019 11:21:40 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42990 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbfJJPVj (ORCPT ); Thu, 10 Oct 2019 11:21:39 -0400 Received: by mail-pf1-f196.google.com with SMTP id q12so4112697pff.9 for ; Thu, 10 Oct 2019 08:21:39 -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=da4d0hY2iIJllCat39rnN5At72u6ND4B/z/GU23BPgwbnchc2Ln767iYlhtzM2MFk1 vFld1qJ9isVcYFaWtbm7U/Ao32TsHEg4DzrLDYYn7rn6fNSLAR+mWBaqxTX7G4N4SOCe p3GWzYIFfJmYDhP530S/DN0X6r/pigoKvIapX4Li+wj1nvyapLRTENzdzMIQhypBr9p8 7anzW03pje1hpCbTA+aazWiI+0CxlHxo2iONh9Bwjr+c+202LkbKlHcPk+QvVwdtg/80 yc2quGikXcjZ8wust/x9YXX+qVewqWZ+3nOvweuJvKdw7RTLiFWEt+rMty06TUkjHt6o rFdg== X-Gm-Message-State: APjAAAXBoKUh7fELuxxndTQ2/vnwJ/0mYl21CRU/0h7ah7KP6KnyxPaY FZQnYVI/c/Xg5s/U8OA/xjWI1u84 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.23.0.581.g78d2f28ef7-goog