Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp526076yba; Mon, 1 Apr 2019 11:04:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzntOAxcJn4btjdixFjiEoSBjNzA1eX5rg4uezK0W+sKfu67TqDCGA1PhaSgFqGv2iqGn0f X-Received: by 2002:a62:480d:: with SMTP id v13mr64868152pfa.125.1554141891425; Mon, 01 Apr 2019 11:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554141891; cv=none; d=google.com; s=arc-20160816; b=Yjps1aIYuBZJh6YHyT+zGrmhLUGH65cwQey+QLCU6HwjIKN1JqX5QZdtuFP7+e2Lx0 ys1I2LCaBqkk5t0KMvnZoJB7yvdBlN2/gbQs8H365BM8u30paTdtNcNTzXykCwrn5+qz 7cZL0Y+nW8nz1BytZUtNpHSnaKVNFwQoNqjmE+pyBo7BOGomxdtQjB4/vVQLb0xfDVBF +Zks/dKQh2TWCd/jAwyJ8/djX/9XQykXSqnj2JAlkeNGLp6OA0eUi5GhpLlm3A/0rxI0 yb8rZFd8UrzlVrS7VI3rAPNzpout6RZo+xRtvnH3dXv3C6NFR8A7Fm5sn/S3b+KXlTAC pLIQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pHyhjiaQzqUO116MKyOAwz7G2Y89NI2w/LNcXgMdHsc=; b=xal7ha9+Fxy291qRxNSJ/t1vp8FvLd78RiuvUaBjm3Eepk0B/WHsuz9bRSYSMKJ/39 hO4VLAfxvNDlM0XKg4IsjTkrYPuwxybHDSXEsX1ljz9qGOoitYXjNQgtrS4RWLUdM/71 XkM+rNotevL+BpylpFP+TbvoSiqSX3Jgj65HkmzXr5Rl0sjp9y5xJ8uvR4EEjCjyraPP uRfe3QkodVal4sN4XVdKZGcgokHV1q6c78PTxfCnt9vsJuOPali7Ch1gpEU1Q8HMZJXc NVJd7gMs0G9bxEfcrJvLgA1L6DNEBZro3+4ns0hF6JCkWfQ+NPm3C76wGncOxsu867Az zqQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YX0wGV4h; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si9746668pla.370.2019.04.01.11.04.35; Mon, 01 Apr 2019 11:04:51 -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=pass header.i=@kernel.org header.s=default header.b=YX0wGV4h; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731169AbfDASED (ORCPT + 99 others); Mon, 1 Apr 2019 14:04:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:37010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730661AbfDAROC (ORCPT ); Mon, 1 Apr 2019 13:14:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC34A21915; Mon, 1 Apr 2019 17:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554138274; bh=UrGUce6tV86wwfOIt89P64fahbh8Zu7YzV0ZSIOmd60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YX0wGV4hao6ToCpOjsX7kFZXgW5IuxpcUjc+6EvxyGumrajHJCNQBL3cfLIIQo45W yws7qSUWsmrRbTK8wAdSWzDQMu49fWYx5sfhobN4Y0tF6lJP9rvdhuLCYiaQu/sEFF TqexyfzexdYuo9Rpxhxhp+CpJDzIGCllsmSYd+Wk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Elsasser , Herbert Xu , "David S. Miller" Subject: [PATCH 5.0 019/146] rhashtable: Still do rehash when we get EEXIST Date: Mon, 1 Apr 2019 19:00:31 +0200 Message-Id: <20190401170050.207097952@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170048.449559024@linuxfoundation.org> References: <20190401170048.449559024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Herbert Xu [ Upstream commit 408f13ef358aa5ad56dc6230c2c7deb92cf462b1 ] As it stands if a shrink is delayed because of an outstanding rehash, we will go into a rescheduling loop without ever doing the rehash. This patch fixes this by still carrying out the rehash and then rescheduling so that we can shrink after the completion of the rehash should it still be necessary. The return value of EEXIST captures this case and other cases (e.g., another thread expanded/rehashed the table at the same time) where we should still proceed with the rehash. Fixes: da20420f83ea ("rhashtable: Add nested tables") Reported-by: Josh Elsasser Signed-off-by: Herbert Xu Tested-by: Josh Elsasser Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- lib/rhashtable.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -416,8 +416,12 @@ static void rht_deferred_worker(struct w else if (tbl->nest) err = rhashtable_rehash_alloc(ht, tbl, tbl->size); - if (!err) - err = rhashtable_rehash_table(ht); + if (!err || err == -EEXIST) { + int nerr; + + nerr = rhashtable_rehash_table(ht); + err = err ?: nerr; + } mutex_unlock(&ht->mutex);