Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1409581ybp; Thu, 17 Oct 2019 12:21:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+o1tvS5VTlSbto9zdGShDwkdTIciWBYo6KnmQEatFnnD9Fwy/bQssixywE6Trurewsfto X-Received: by 2002:a05:6402:656:: with SMTP id u22mr5627991edx.70.1571340097276; Thu, 17 Oct 2019 12:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571340097; cv=none; d=google.com; s=arc-20160816; b=dp3h4fsQsOCBAR/MqFHxoO3PWLbSkhrFQ8DaAHzDJW2AhimVolFuDW/DIcRJvFWr1b WwS11JlASr5llXWTUujPd4npJGIfOUNkv2X1MTrXUCtOu7QUfV+lZ7t+YyvkaK5ngmbX DVlyHSHmPnnc0Ci9xPguaOQQ7qkmO0kVDoanRYNm3YAonaV0hEecE6fXlJMfpBV9VOwZ balRIm81Enn91DGbelrzeYV6GncDm9Z7KrZkGumOrfOJ5KpR/+sRokAVALKWG2bXzRl1 po3JCsVCa8zPA1jfh6TlkGw9Ro3AaOiHuKcG8LTKewd8gWR0LazMfeefRUhj7pohSdl4 5erw== 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=RfM03BHBRqHRHJksrlqWg2J/oW/6Gvfth/o9MJ3qWsw=; b=KkTB5AQg0NttkfJ6F37WHc1KktqbfhR84PVqsCUIIbmwz84WUm0/oD0g4Zcsfnnc+Y kibm6/UVWLBiNdrYFXvQ95b1G7BLCrStJ5cWpNwxhSlzlQEMXh1bKzg5ALxQcBjKTx25 TyBDeDmNhKEYOoLuwFPmx/3rs0xbmSfqqmz/4wuogWVbwspLwYJS0twWP4Mpt1T0mkPi vzd4UYG5iAm32/elBCgLo6lIybBCcRL4LN5mv9omCufFXFCUWezM/cGuGnSyXrLntFgE r+tqa0N+//WC/877JJzBKIk3oQBMu7uNYXw9fG83aYgurFuwzQLaonHkfEl3XsXqzH6H giGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VCnvbCrp; 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 y16si1966684ejc.34.2019.10.17.12.21.13; Thu, 17 Oct 2019 12:21:37 -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=VCnvbCrp; 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 S2439367AbfJPWPd (ORCPT + 99 others); Wed, 16 Oct 2019 18:15:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:45988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437741AbfJPVzX (ORCPT ); Wed, 16 Oct 2019 17:55:23 -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 94E4F21925; Wed, 16 Oct 2019 21:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262922; bh=RpGTqagJB6A2tt+p5GnQxTSznwvHVQuX/VHEtXgNcBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VCnvbCrpZttpVeIV10gZ3ecbWVD92XvW5YF9DFEXw44ugODlnD0jhnmYk1Ctn6hZu oQyKunTHTKXaDqqfafJGDItg4mLJH/gJxKUzu35MTNJdqB/vxXn3Dp7LbKHUpMWjMx ZIjWJGFAKZEu+VXbJCLxFlrPTuiP5KQ2fgeZTbzk= 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.9 82/92] kernel/sysctl.c: do not override max_threads provided by userspace Date: Wed, 16 Oct 2019 14:50:55 -0700 Message-Id: <20191016214847.223376846@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214759.600329427@linuxfoundation.org> References: <20191016214759.600329427@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 @@ -2356,7 +2356,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; @@ -2368,7 +2368,7 @@ int sysctl_max_threads(struct ctl_table if (ret || !write) return ret; - set_max_threads(threads); + max_threads = threads; return 0; }