Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1058745ybp; Thu, 17 Oct 2019 07:28:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqz16G/+aXAbYb0KTkwfDjMpztpuDX+44niYVtIHvMskhsmX3ajSRdrc+jQsXslMJsBgEih2 X-Received: by 2002:a50:cb86:: with SMTP id k6mr4132727edi.270.1571322516609; Thu, 17 Oct 2019 07:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571322516; cv=none; d=google.com; s=arc-20160816; b=jXb6macxwVKUQL3oInkJ768VpiG8lMBQFHwYx6SjOaQwqqau7miJv1tqeo2v8/aSYz 5I6KOQTjLUrxp9TZxhDUjg4x79s6l4H8vCCS8QdIYdwB37YlEpPRtmLDs38Lu6lddXrj 2pelxgvBOIgAWnBPXEvQ70PnDS0rF59wfxt4kkpLW7XjUnJ8mI6E9cQGsEiShLH6M3Qi Mc2BXfT/swzvpmX7R2kmlIxi5lOjX70wk7wf0kqyGLMjmxZaKwrIpcfEiQz55J/L2fqS q8C37K7zReOT/8UAU6QkcLieyudIxDF820yuz+GCo7aBvbgK0NSn2Ssnzfx5+pNGYrhx 5big== 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=TJXXOnfdoAvG/02tyNf63Odg9HPi+m7csCG1+LgrxoM=; b=uzTD/gpUxz61jbPILZ+z5FYfTt0OtRgEGvWNbEdbE2MkEbBVIQPkd4fZ5/EgNBvKql gktzWFdn6hi2kEgcGxmP96OumIMR90AVEu1qOltEmO1O2BhF9E7+cATfruCMOlGug2pV jVQ557kPYUZGVDRPiBJSgwzicMTUHTnw1CSzh5uXMoC27E3T3uVhDWOKSvzyebofMiii XxW5Fo6mhaWEOyzYA5kWi7PgLWWj9XhVwnPJrF0HDU3b8wcXrOcEP6EF9CT8230LBG+L 4GGy9IanbeVRGYCGRLUV4Q8iCCNQE+Q0ewjAoz7YmUZTaHa0o29HnKVvk2YB+kaevR3g NorA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lL4fL7tN; 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 q13si1473240eju.46.2019.10.17.07.28.12; Thu, 17 Oct 2019 07:28:36 -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=lL4fL7tN; 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 S2395382AbfJPV4g (ORCPT + 99 others); Wed, 16 Oct 2019 17:56:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:47886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406627AbfJPV4U (ORCPT ); Wed, 16 Oct 2019 17:56:20 -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 AA9D820872; Wed, 16 Oct 2019 21:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262979; bh=J2Sn1aG9tQc5zNbTM4373KlEXNztfHo5wQ38E+AP4+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lL4fL7tNWtc1offacAvhniuKZfFqHTqwnH9XklgC2wPIMc/CxqaNBphOhRUvtzLYc hRsD8/6tzc0kHNBQZQFSb+ZWET0/Cgx6tyxwF0Mc+bQMznwHEiLpDQgghbj0c59Ebq +ehowKj5gTyYTivLmyAFTw14diVuaSm/0F4WnK2E= 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 4.14 49/65] kernel/sysctl.c: do not override max_threads provided by userspace Date: Wed, 16 Oct 2019 14:51:03 -0700 Message-Id: <20191016214835.534949867@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214756.457746573@linuxfoundation.org> References: <20191016214756.457746573@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 @@ -2499,7 +2499,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; @@ -2511,7 +2511,7 @@ int sysctl_max_threads(struct ctl_table if (ret || !write) return ret; - set_max_threads(threads); + max_threads = threads; return 0; }