From patchwork Tue Dec 18 06:52:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10734897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED5E214DE for ; Tue, 18 Dec 2018 06:53:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCC2C2980B for ; Tue, 18 Dec 2018 06:53:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D096129997; Tue, 18 Dec 2018 06:53:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6605C2980B for ; Tue, 18 Dec 2018 06:53:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 701858E0006; Tue, 18 Dec 2018 01:53:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6B0A68E0001; Tue, 18 Dec 2018 01:53:41 -0500 (EST) 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 5A1F58E0006; Tue, 18 Dec 2018 01:53:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 191228E0001 for ; Tue, 18 Dec 2018 01:53:41 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id s14so14277035pfk.16 for ; Mon, 17 Dec 2018 22:53:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=ePPYYhEr//iooFSafpmzBrgxTNLsUtWOPHNz8MuPfvg=; b=SJ2xyV88SoHQlOEHKruPQGe9OIhM+kCEOQ0QDlPZAGMH8bhfjr3O8iYXP3KFrToXCx Ru1DJglFyhuTTkKyfBOMZFiGFTcvRbtXtOiwo5M5qCRw14YxKBUl98yslXic5CrwC8dj Z+MbJRTzpkRzq/qarKlSwePFIWwR0lI2nrVf5lBB5URevZQ5nWfHQUVwKKmB2f/v9Ky9 I61zyb400LssqJ1mTW+E/8yb4/F22sFkP6LBAJi62M+GwKaS5kKC+d0/mvylaETNv/op NaWNWckqYVTps5ETqe50M6nVTTHXreghO/BzvC58GtZMb3evIHMUnKcj/modzNuQBCEi WN8w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AA+aEWZVhGE8yunx4MANX1ZRbf7J+F30BMdyT+30PglIItTUUdEZz3Dj F+dqUipXNVcmpgTlNMZ2xWhact8Iw5U4Ekpk+Q2BHB2mHLcaVCaasYE3WHO80STOxRkUSUxlPx6 971XLFtj9o/7wYAp0d0wBgUq6Mx8JICDmkyZYZu7pMbzY4bAb9zUKRvINgGv0VPkfzQ== X-Received: by 2002:a62:7e93:: with SMTP id z141mr15281384pfc.239.1545116020789; Mon, 17 Dec 2018 22:53:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/UK1bO6SnpttIvbn1B3QuBfAKI/n15i4pwk0jDytmLy4I4zVU085YVZ3UAqXMXbLqf8kLad X-Received: by 2002:a62:7e93:: with SMTP id z141mr15281358pfc.239.1545116019729; Mon, 17 Dec 2018 22:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545116019; cv=none; d=google.com; s=arc-20160816; b=H9yc08kjgGrHuOwmWWZLhsyhayuZ4XnXDl05LzSNAbUxtI7qElj9aYDo5VblEE1QQw TWXsmioQ0bnUYuM0yULF0l6BFJZ5EIyZjVMJ3kerRCaSdLYnagAqhg1+tyJNHaTTN9I1 41E+FL2sU6wE9+mHkHKigxjUkkzoOSUgmeSx35cXBNcOlZcTXe+/GazfUl91BQub4ebt fG/rLvO1SImrG3LLaEX3SXuqQM9+K94LiScLT0dqT1QO/yplyX+aNAHSu7fWeXGnWao4 n2uBKCrqGalg7fdFXn4FADC/rrYPPZ0kfwDqm/dO2IYi7s81h4Od6mmroEPCTLpTo4e3 3CTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=ePPYYhEr//iooFSafpmzBrgxTNLsUtWOPHNz8MuPfvg=; b=hYDLAXhgMvcxFTvYbPajrXhD1p6Ss4gTSnsQ4KFxYi74bCuFbZBPYG2Kv0U9tBEECg BxV477RHK2mV2K33Q9dspLmlWQj7GHAgUT25bHgXkGvBmVi2vbJQJ6PDTnRsvIcS0qHU mRVZAmWPHh+o7jZ2d4K8lQ8ixY83DkApcAASqW4GgKTnfS3uns/tcTPXF2N72tT2hRF6 lKKTN2bekInSWkX/7i2MzDtmouqgSGOHG+Wgckl792M84ZZrXXSdENIKBKW4BGzAg3V5 KeurcEOpmBna/wJkmNH4Gqp5xCF3Vm0HM5vp9RIYhDTOZEsTEUgHgIXHSlESsoA08w/4 nzxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4436.biz.mail.alibaba.com (out4436.biz.mail.alibaba.com. [47.88.44.36]) by mx.google.com with ESMTPS id 66si12427233plc.125.2018.12.17.22.53.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 22:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) client-ip=47.88.44.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R591e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01419;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TG1j1yV_1545115948; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TG1j1yV_1545115948) by smtp.aliyun-inc.com(127.0.0.1); Tue, 18 Dec 2018 14:52:35 +0800 From: Yang Shi To: ying.huang@intel.com, tim.c.chen@intel.com, minchan@kernel.org, Andrew Morton Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/2] mm: swap: check if swap backing device is congested or not Date: Tue, 18 Dec 2018 14:52:27 +0800 Message-Id: <1545115948-25467-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 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: X-Virus-Scanned: ClamAV using ClamSMTP Swap readahead would read in a few pages regardless if the underlying device is busy or not. It may incur long waiting time if the device is congested, and it may also exacerbate the congestion. Use inode_read_congested() to check if the underlying device is busy or not like what file page readahead does. Get inode from swap_info_struct. Although we can add inode information in swap_address_space (address_space->host), it may lead some unexpected side effect, i.e. it may break mapping_cap_account_dirty(). Using inode from swap_info_struct seems simple and good enough. Just does the check in vma_cluster_readahead() since swap_vma_readahead() is just used for non-rotational device which much less likely has congestion than traditional HDD. Although swap slots may be consecutive on swap partition, it still may be fragmented on swap file. This check would help to reduce excessive stall for such case. Cc: Huang Ying Cc: Tim Chen Cc: Minchan Kim Signed-off-by: Yang Shi --- mm/swap_state.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/swap_state.c b/mm/swap_state.c index fd2f21e..7cc3c29 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -538,11 +538,15 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, bool do_poll = true, page_allocated; struct vm_area_struct *vma = vmf->vma; unsigned long addr = vmf->address; + struct inode *inode = si->swap_file->f_mapping->host; mask = swapin_nr_pages(offset) - 1; if (!mask) goto skip; + if (inode_read_congested(inode)) + goto skip; + do_poll = false; /* Read a page_cluster sized and aligned cluster around offset. */ start_offset = offset & ~mask; From patchwork Tue Dec 18 06:52:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10734895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1454414E2 for ; Tue, 18 Dec 2018 06:53:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA7E52980B for ; Tue, 18 Dec 2018 06:53:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB14329853; Tue, 18 Dec 2018 06:53:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1466F2A61D for ; Tue, 18 Dec 2018 06:53:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 220308E0005; Tue, 18 Dec 2018 01:53:36 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF398E0001; Tue, 18 Dec 2018 01:53:36 -0500 (EST) 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 0BEA78E0005; Tue, 18 Dec 2018 01:53:36 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id BEF8F8E0001 for ; Tue, 18 Dec 2018 01:53:35 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id d18so14350071pfe.0 for ; Mon, 17 Dec 2018 22:53:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=rC0hp/kPrftj0ss+ibLBEcPgTikAvUuW0SpOhQIUcfs=; b=IUhc8LgRdlpJYt2jMKtB81z6+/rvpE/VaQh5pOle95qamLGuS+9q5bA28ki0ndep/x LdybjoStHf9Gxltz2wKjIyQKFPWAw9dRhxnTBXf/MaOMo8AJOdW8cte7pH2K9WoFmWJb IjRDfM4oAf3IkLQuiU53uKnfZyXPIHo7imYqpK0UegV9eT4BDWaUHuP3rWBEi3qO8D8m 1z/Bl1f8e6wD2X+q3KQQHuYWomLPkDGREvtj3eG2xgC6Jsqo7fxicHe7tAqkKCG7WVxs ntb1Um41FqhLYW8fr0diX70KUW3c/JOz+HwrEY4XJ+6Ms5wUuIxepUTMKAu26fLWhu7Y 5oYg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AA+aEWYCU7ST/Qr98/2ajoZunRMzYKjJnCWL0VgV3ZpWilBaLD6HqTwS ZpdnId1n00GFqLY9ab5XARKVQIpYheUe87mkCuyEycyR9Q3W7Omo7enUfMS3y5OZ44YYoYZW1yd TXoVv7ODct97tuDXc75lAViSaN+r74UZiJJSAA9+LkHmNYimAn4HEQlYg5vsPEWK5PA== X-Received: by 2002:a63:1e56:: with SMTP id p22mr14658832pgm.126.1545116015429; Mon, 17 Dec 2018 22:53:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/WEiUD5vTv///jxdM0V98Li4GmBJh89Avbz2XXI0f5BZEFxxJWL5YDWo7h9O6MXA7FMfE+U X-Received: by 2002:a63:1e56:: with SMTP id p22mr14658791pgm.126.1545116014411; Mon, 17 Dec 2018 22:53:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545116014; cv=none; d=google.com; s=arc-20160816; b=cT+OLO9BF/8E1el1PU29ya18bAcbMFjtT2hJ+bDStOs+OJAVezk3+2Pca79EZyhKJB 7zZoAYiMpKAi2NlzB/ntiN2jxcmrlAo+KRuIwHNNXAgoI2Xlm4oqyzDRN1y+CtGHD1M5 wbJA5st1FbdzZp91H6/hBwwIx3V8KSratvoQKBWnrc34D3fIqfrfXTX5baeEEMn850oP wTskJsmSUhervfPu9LJ3YwLDXSB89rSUpOMOL1U/wSQyrP8+g0rJZlwZ3yVC7ivUXV3J T8Aj8YkniQAx4FK7e1NFJMM669tIRERvaptUBMHDlGmVy5dijJFuHnoaQj1xlrQYQ7ae pwqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=rC0hp/kPrftj0ss+ibLBEcPgTikAvUuW0SpOhQIUcfs=; b=08batfeiBMDwwu3RqB1PK8W9Dv6hFM20+12A5vKG1jMtTs3JNVd3U+elyuOdXh2GPz duO1zNZIHmlMery9b8/Ah4UP30MXEI+g6EHuh/F4fW8/sQanj3xEj0juQHwbVXLVGIvC rl2Os0WPtL0R8D/XpVwJsrCcqRg+ibgQdQ357m5uJeAfSUkFAKkF760f9eVRNvtzWBVH +qy4k/5frbmpOi/18IJGn+eCS/Gh0XEDZCmGftAs5vFChzOP960h5B2gNreoHwjlXkDr ALbUW6NvbHTrf9x30IUftrT+uNoomb5QriD8USK0LO2LTRdXGFgiYUKjmx7heQ1QdAcv dCTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com. [115.124.30.133]) by mx.google.com with ESMTPS id r27si12934921pgl.494.2018.12.17.22.53.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 22:53:34 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) client-ip=115.124.30.133; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R561e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07486;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TG1j1yV_1545115948; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TG1j1yV_1545115948) by smtp.aliyun-inc.com(127.0.0.1); Tue, 18 Dec 2018 14:52:35 +0800 From: Yang Shi To: ying.huang@intel.com, tim.c.chen@intel.com, minchan@kernel.org, Andrew Morton Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/2] mm: swap: add comment for swap_vma_readahead Date: Tue, 18 Dec 2018 14:52:28 +0800 Message-Id: <1545115948-25467-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1545115948-25467-1-git-send-email-yang.shi@linux.alibaba.com> References: <1545115948-25467-1-git-send-email-yang.shi@linux.alibaba.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP swap_vma_readahead()'s comment is missed, just add it. Cc: Huang Ying Cc: Tim Chen Cc: Minchan Kim Signed-off-by: Yang Shi --- mm/swap_state.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mm/swap_state.c b/mm/swap_state.c index 7cc3c29..c12aedf 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -695,6 +695,23 @@ static void swap_ra_info(struct vm_fault *vmf, pte_unmap(orig_pte); } +/** + * swap_vm_readahead - swap in pages in hope we need them soon + * @entry: swap entry of this memory + * @gfp_mask: memory allocation flags + * @vmf: fault information + * + * Returns the struct page for entry and addr, after queueing swapin. + * + * Primitive swap readahead code. We simply read in a few pages whoes + * virtual addresses are around the fault address in the same vma. + * + * This has been extended to use the NUMA policies from the mm triggering + * the readahead. + * + * Caller must hold down_read on the vma->vm_mm if vmf->vma is not NULL. + * + */ static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask, struct vm_fault *vmf) {