Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp12357099imu; Tue, 1 Jan 2019 21:47:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN7rlt0u8hPs32YYe8Zeme5jrOKfbZyWzpE22ZG1eHIdxve8F0TVL3hAAHUdASAOEl+oLNm+ X-Received: by 2002:a63:d301:: with SMTP id b1mr12578348pgg.61.1546408041529; Tue, 01 Jan 2019 21:47:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546408041; cv=none; d=google.com; s=arc-20160816; b=cKX+VMFy4ksO041WqKE+Eop26X+QBmmZMuKJ1KaAMVPf65X/5Ec5oqXqHzhBX0KIjV QaU+G1u3idrw870qsyx4+DyvLHAQ+GvLtv11edfCZYH7ROwRP6DexZZb1CmrUW9XH8Ix yWSvx2DUsANNS2N88/wdNT+qBVRRabmhN4QrZb8eISW3MeBL8JzU2uJPN7izqppN6G+m Sei6rB5k0f44bKqi0Hyd0VCcMX/OqlfM+zcx4sMsjVEtfD3ag+W4rVr2cTedKl9MoJOe ATz3IntBMxDjtpCzACDm9Y2AfQgHHQMioLkAK27tfvu5OHaLHitRJ8LZepdPb5aX78Bn cFkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=sGf8qo2Wdx2LK1OhcJgrgfHsKFZtTfQlC5pl8JudtzE=; b=j400XNKC/08Uh3O8hD2o2hKiY5gb9wOr86xU/TBsymFsCdr4PKWIrvQo/fYf2yGtCX KTtXIk9NwtILT7rKOylh5YXmFfATiS4bGqrbssQlhxBo+gsI+byntN8DiZqXUv1q+kjQ J34ZUParjktv5l3uzm4fz9jhb0DT7q7+rut2h5TXN0quVEHmfwN6ih+Dsa9+gRhZzafN rAsnNwtFeS+ZHvxcTE1lXgYquGR+riMoHL36qfb5U/Py0RRxjsMYRC60XW6TE3R2EkyG lD1vWtA50HxwS9YIvxyTUmxiZ7By6xeZR8EelCOaJRViSiy0PIPgIX2lkS4OL4933OXH 9UAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TlDyqnPH; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w27si17566190pge.182.2019.01.01.21.47.04; Tue, 01 Jan 2019 21:47:21 -0800 (PST) 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=pass header.i=@google.com header.s=20161025 header.b=TlDyqnPH; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728342AbfABEQj (ORCPT + 99 others); Tue, 1 Jan 2019 23:16:39 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:46462 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727995AbfABEQj (ORCPT ); Tue, 1 Jan 2019 23:16:39 -0500 Received: by mail-ot1-f68.google.com with SMTP id w25so25802518otm.13 for ; Tue, 01 Jan 2019 20:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=sGf8qo2Wdx2LK1OhcJgrgfHsKFZtTfQlC5pl8JudtzE=; b=TlDyqnPHZSSgvwoclhmoj5ys8xDZm6AlFzh05iWq49a0NRex24EjU20DyAzpNHTUT9 uRytyqszNnfGIMXVM/NFBwcNXsFtkxYspclXZAz3c2+g15YObn+SUogf8XaTA8DIeE2K ocCl0fV6dGBnOPKUF3b97m7ySSCWjVhPDwUhr2YyuSNUkfxZqr+XiZTD+K/u9s10C9Zf Le5E3McHGCXl1ohRSkIOtmOyLYHTVM7ChSDXX3bf6Ps5+9Ln/adFK1P4iSr6jK6ZYm76 fR3gRj5Y1C1QVCMJi4sqEETFCjfuEZMOZApxYz1eqmVGlwetjzwxPK+81yhXcQPCYQoy 14IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=sGf8qo2Wdx2LK1OhcJgrgfHsKFZtTfQlC5pl8JudtzE=; b=s8/55fC2fzYAeS6sTGDOhhovhu7Sa/esd4MSaeb9FUvlATaNgQ0ediEYz/EijIpfGf ytTPh7x5whbKcJxB3gZSmE6g73ILZkmfSccgfr+lM+FaqVFp9sB8UZiRmnS8CEsVcMA9 JVw+ADPNck9RTpkyhi6f+zC1yVxJQakh+p41+LfCJiOVYvW/g1KNVrD69S4eeTBQBUww //V/1NUXbHoDSDF79W6YuCZCTYtpfnmKMy0Z2h/z2zHMlKPAmmcyxgFzxUg4n72+hInl SqJvYR1l2Sp49gmdJZdXrDPuU8Mk0tWeah8yTzghhTVf7/rUhl6zodLgpERy0gHmvkBR X8tQ== X-Gm-Message-State: AJcUukdJZoE7qfOmvlqUkA9k+oYDXGcb9U8leJSnGpG5s7f3ABJzwMwr uzH1MR59BUQBOz4AP20tHnHPo5EMD1U= X-Received: by 2002:a9d:1421:: with SMTP id h30mr28318662oth.321.1546402597919; Tue, 01 Jan 2019 20:16:37 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 21sm29760692oie.24.2019.01.01.20.16.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Jan 2019 20:16:37 -0800 (PST) Date: Tue, 1 Jan 2019 20:16:28 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Vineeth Pillai cc: Hugh Dickins , Matthew Wilcox , Andrew Morton , Huang Ying , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kelley Nielsen , Rik van Riel Subject: Re: [PATCH v3 2/2] mm: rid swapoff of quadratic complexity In-Reply-To: Message-ID: References: <20181203170934.16512-1-vpillai@digitalocean.com> <20181203170934.16512-2-vpillai@digitalocean.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 1 Jan 2019, Vineeth Pillai wrote: > Thanks a lot for the fixes and detailed explanation Hugh! I shall fold all > the changes from you and Huang in the next iteration. > > Thanks for all the suggestions and comments as well. I am looking into all > those and will include all the changes in the next version. Will discuss > over mail in case of any clarifications. One more fix on top of what I sent yesterday: once I delved into the retries, I found that the major cause of exceeding MAX_RETRIES was the way the retry code neatly avoided retrying the last part of its work. With this fix in, I have not yet seen retries go above 1: no doubt it could, but at present I have no actual evidence that the MAX_RETRIES-or-livelock issue needs to be dealt with urgently. Fix sent for completeness, but it reinforces the point that the structure of try_to_unuse() should be reworked, and oldi gone. Hugh --- mm/swapfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- mmotm/mm/swapfile.c 2018-12-31 12:30:55.822407154 -0800 +++ linux/mm/swapfile.c 2019-01-01 19:50:34.377277830 -0800 @@ -2107,8 +2107,8 @@ int try_to_unuse(unsigned int type, bool struct swap_info_struct *si = swap_info[type]; struct page *page; swp_entry_t entry; - unsigned int i = 0; - unsigned int oldi = 0; + unsigned int i; + unsigned int oldi; int retries = 0; if (!frontswap) @@ -2154,6 +2154,7 @@ retry: goto out; } + i = oldi = 0; while ((i = find_next_to_unuse(si, i, frontswap)) != 0) { /* * Under global memory pressure, swap entries