From patchwork Wed Oct 9 21:18:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11182183 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 090EA1668 for ; Wed, 9 Oct 2019 21:19:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA60B2190F for ; Wed, 9 Oct 2019 21:19:04 +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="IElwFySM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA60B2190F 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 078566B0003; Wed, 9 Oct 2019 17:19:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 029678E0005; Wed, 9 Oct 2019 17:19:03 -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 E5A318E0003; Wed, 9 Oct 2019 17:19:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id BDFC16B0003 for ; Wed, 9 Oct 2019 17:19:03 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 51E0A45A8 for ; Wed, 9 Oct 2019 21:19:03 +0000 (UTC) X-FDA: 76025511366.25.pin83_892df6f6ea330 X-Spam-Summary: 2,0,0,90da97d3a3644484,d41d8cd98f00b204,minchan.kim@gmail.com,:akpm@linux-foundation.org:linux-kernel@vger.kernel.org::minchan@google.com:hannes@cmpxchg.org,RULES_HIT:41:355:371:372:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2890:3138:3139:3140:3141:3142:3353:3865:3867:3870:3872:4042:4250:4321:4605:5007:6261:6653:7576:8957:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13894:14096:14181:14394:14721:21080:21444:21450:21451:21611:21627:21740:30001:30054:30070,0,RBL:error,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:326,LUA_SUMMARY:none X-HE-Tag: pin83_892df6f6ea330 X-Filterd-Recvd-Size: 5097 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Oct 2019 21:19:02 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id z12so2228076pgp.9 for ; Wed, 09 Oct 2019 14:19:02 -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=yIVzU+Q0uxcUt161uhYqfP3XsKR01P4YLhVu2FbVi3E=; b=IElwFySMYED1EECdhFj/UA9KqWeh68mdepLNVjqkB46MCKh7Vd0WHdQAc2HutK0/dn obYW+/5aA9BKVEeV63+7iBt07fKD/fIDojpUJWViLx7pYzR5BGz2g+beTgqBOCnVGs4x XKpKEkss0J+rprIl48Z9vUecQXatM2HGbIQi9mhwdsUPMZ+iqSwbIRmvshmkHCFHQ4iM P0WjQMcNRZVOYcNvp/HaYzE8VzGnbZEkOnge57htd+rG06/SHm88gyb0OcvWorQn2p+a MknWchyQFTctfA33GuFlgty0SenHEUEd6DWkBu+t6fJFq34XDxkyQySNjXRe6dC3GBp5 pfuw== 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=yIVzU+Q0uxcUt161uhYqfP3XsKR01P4YLhVu2FbVi3E=; b=TDyS3GGlx72v4GEDwXMQl10kXtJF25ooiIt3B2l6CK9QtetCOwTcR+jNt6tFl8N7fR 0eZeekAcGq/61mPX8FE0C3rQroPHecN88TNyMfuK0/bD0cFgUJ1+hi+FwDh/z2EQkNn0 3kTLncfD0DRaY6wZVFXXj9uZc6nvYnHNwOCrIOpPz4EjFy4bB0vkEoUCILEWSRV2JliN UfT0oOfb35QhKkGteQGX9oEurJQ9zmbB52fwVVBqoDLRbDo+zyfMdQAMrnIqEsKiC4jh WcicQ7wUYWsf1u6sfiY2SOZu6wXmdgmKw5XT/FwMNqOormFiD1PKWWbmry1E5TZNaTzy NdJA== X-Gm-Message-State: APjAAAWpgyXJeIkvryjgCCWhYd+bL3X7nVjoUE+PiD9eAxt2ydud5scz XGKT2rbfG6Ugyl7F8sEk5pc= X-Google-Smtp-Source: APXvYqw2sNXhHHFIyhGh+CGGz179BRZrGUzG1ZAnoUqCoueTnKRiqdz3ZodwQmvEnqnXzp/uG3No6g== X-Received: by 2002:a63:a35f:: with SMTP id v31mr6539319pgn.51.1570655941446; Wed, 09 Oct 2019 14:19:01 -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 e14sm2610659pjt.8.2019.10.09.14.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 14:19:00 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: LKML , linux-mm , Minchan Kim , Johannes Weiner Subject: [PATCH] fs: annotate refault stalls from bdev_read_page Date: Wed, 9 Oct 2019 14:18:57 -0700 Message-Id: <20191009211857.35587-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. Annotate bdev_read_page() to account the synchronous IO overhead to prevent underreport memory pressure. Cc: Johannes Weiner Signed-off-by: Minchan Kim --- fs/block_dev.c | 13 +++++++++++++ mm/memory.c | 1 + 2 files changed, 14 insertions(+) diff --git a/fs/block_dev.c b/fs/block_dev.c index 9c073dbdc1b0..82ca28eb9a57 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -701,6 +702,8 @@ int bdev_read_page(struct block_device *bdev, sector_t sector, { const struct block_device_operations *ops = bdev->bd_disk->fops; int result = -EOPNOTSUPP; + unsigned long pflags; + bool workingset_read; if (!ops->rw_page || bdev_get_integrity(bdev)) return result; @@ -708,9 +711,19 @@ int bdev_read_page(struct block_device *bdev, sector_t sector, result = blk_queue_enter(bdev->bd_queue, 0); if (result) return result; + + workingset_read = PageWorkingset(page); + if (workingset_read) + psi_memstall_enter(&pflags); + result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, REQ_OP_READ); + + if (workingset_read) + psi_memstall_leave(&pflags); + blk_queue_exit(bdev->bd_queue); + return result; } EXPORT_SYMBOL_GPL(bdev_read_page); diff --git a/mm/memory.c b/mm/memory.c index 06935826d71e..6357d5a0a2a5 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2801,6 +2801,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) if (page) { __SetPageLocked(page); __SetPageSwapBacked(page); + SetPageWorkingset(page); set_page_private(page, entry.val); lru_cache_add_anon(page); swap_readpage(page, true);