Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1346405ybp; Thu, 17 Oct 2019 11:23:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvvEtprtTVTYhF2R386xJxPbP+oWmcdYB+3NPoP4xltvaOr3Y2diJs8TBH6gSMj8Wg7iu6 X-Received: by 2002:a17:906:29db:: with SMTP id y27mr4894000eje.185.1571336597968; Thu, 17 Oct 2019 11:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336597; cv=none; d=google.com; s=arc-20160816; b=JetDp8OWxfBzPR4POuIqxYZ0YHNtggOlXFKrkrZL6JBCOJ5RDUopFqXJmslW24ltMh +Q3tSvB1eAkzlq0OQnzvHTQkfwGoT7t1fdLX6niY+u04LeK4y6kET+wVoojbdYNg/To2 lQZtqmDmSfeD7EkI/w/of/jm6Ql8yoDH593EBLzVz9bW7rJZkfIoPZatUJVx5QW/9yjP aPggXOPkH4tpDEdz/iwULkaihXl21HUDtIStVRiceIgmLoli1ynFkDeVco4JSr21JuUE 0HzSiPVls4x/pJNlmuldS8Syb3nvLVG7cDAgFEUmxST8l2VN5cpcInZwugntJ9J+07CE d+CQ== 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=neiy3RCJxZKzN+RKcWK4jUt8psD0UOwjHrzcsprhhqo=; b=UIuGcq7Wmn1ruYvsebqjZAcEhtds671BQyKkGJMrHG2yhA1tzoz+k0ef8UhfBD3Ew+ xUEz97wX68JYdfSLJQgMb6RMb7XTej7T8mpRqZp1GENDpwV8iiyU++Q9KOWvYbG7nlPz xAxINu8gOc7NzDz57bCapALi8wOuyjAe1mETTaP5JCxgMQRYJmQrVe2a9BcSJT23r5Vd 4mm96JfijfEkKKp+zq7oJMAMfh6crPr3/4RC3HzRt8yMcKP2Va9FYSz5seeWsbSZUKdz bKVb9SawkyBAUUSkLvGyujXvTgRbFiqEQSKVUgjfDI8kc785lA/cn31UeSDA1P5hNvRu U/Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XR6j9bdR; 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 l22si1944769edq.174.2019.10.17.11.22.54; Thu, 17 Oct 2019 11:23:17 -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=XR6j9bdR; 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 S2438986AbfJPWCO (ORCPT + 99 others); Wed, 16 Oct 2019 18:02:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:55026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438635AbfJPV7s (ORCPT ); Wed, 16 Oct 2019 17:59:48 -0400 Received: from localhost (unknown [192.55.54.58]) (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 CCFC421D7A; Wed, 16 Oct 2019 21:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263188; bh=fGjBvwbJAILEISJRXoOExesOnF4xhwaj6G/DEAlXi2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XR6j9bdRecxpj02RFpoNesOl89ePlX76DCnUKo8ylfdzk76U7fa6GAeqqFTcgLuf7 s4YBPtuWVwdLLLj2s+hpO2z6/e1MRtAcE+Tmp3IQGqd2YZw+oGy2J/68AddwJEnWJI OR1czS1w3cnWGSBAccGuTrUJBXwliVfLVUTwlm1E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Hocko , "Eric W. Biederman" , Heinrich Schuchardt , Andrew Morton , Linus Torvalds Subject: [PATCH 5.3 075/112] kernel/sysctl.c: do not override max_threads provided by userspace Date: Wed, 16 Oct 2019 14:51:07 -0700 Message-Id: <20191016214904.052268850@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Michal Hocko commit b0f53dbc4bc4c371f38b14c391095a3bb8a0bb40 upstream. Partially revert 16db3d3f1170 ("kernel/sysctl.c: threads-max observe limits") because the patch is causing a regression to any workload which needs to override the auto-tuning of the limit provided by kernel. set_max_threads is implementing a boot time guesstimate to provide a sensible limit of the concurrently running threads so that runaways will not deplete all the memory. This is a good thing in general but there are workloads which might need to increase this limit for an application to run (reportedly WebSpher MQ is affected) and that is simply not possible after the mentioned change. It is also very dubious to override an admin decision by an estimation that doesn't have any direct relation to correctness of the kernel operation. Fix this by dropping set_max_threads from sysctl_max_threads so any value is accepted as long as it fits into MAX_THREADS which is important to check because allowing more threads could break internal robust futex restriction. While at it, do not use MIN_THREADS as the lower boundary because it is also only a heuristic for automatic estimation and admin might have a good reason to stop new threads to be created even when below this limit. This became more severe when we switched x86 from 4k to 8k kernel stacks. Starting since 6538b8ea886e ("x86_64: expand kernel stack to 16K") (3.16) we use THREAD_SIZE_ORDER = 2 and that halved the auto-tuned value. In the particular case 3.12 kernel.threads-max = 515561 4.4 kernel.threads-max = 200000 Neither of the two values is really insane on 32GB machine. I am not sure we want/need to tune the max_thread value further. If anything the tuning should be removed altogether if proven not useful in general. But we definitely need a way to override this auto-tuning. Link: http://lkml.kernel.org/r/20190922065801.GB18814@dhcp22.suse.cz Fixes: 16db3d3f1170 ("kernel/sysctl.c: threads-max observe limits") Signed-off-by: Michal Hocko Reviewed-by: "Eric W. Biederman" Cc: Heinrich Schuchardt Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/fork.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2939,7 +2939,7 @@ int sysctl_max_threads(struct ctl_table struct ctl_table t; int ret; int threads = max_threads; - int min = MIN_THREADS; + int min = 1; int max = MAX_THREADS; t = *table; @@ -2951,7 +2951,7 @@ int sysctl_max_threads(struct ctl_table if (ret || !write) return ret; - set_max_threads(threads); + max_threads = threads; return 0; }