From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v4] tools/xenconsoled: Increase file descriptor limit Date: Fri, 27 Feb 2015 16:26:36 +0000 Message-ID: <54F09ABC.30208@citrix.com> References: <1425053045-17592-1-git-send-email-andrew.cooper3@citrix.com> <21744.38837.455720.204222@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21744.38837.455720.204222@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Wei Liu , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org On 27/02/15 16:13, Ian Jackson wrote: > Andrew Cooper writes ("[PATCH v4] tools/xenconsoled: Increase file descriptor limit"): >> XenServer's VM density testing uncovered a regression when moving from >> sysvinit to systemd where the file descriptor limit dropped from 4096 to >> 1024. (XenServer had previously inserted a ulimit statement into its >> initscripts.) >> >> One solution is to use LimitNOFILE=4096 in xenconsoled.service to match the >> lost ulimit, but that is only a stopgap solution. >> >> As Xenconsoled genuinely needs a large number of file descriptors if a large >> number of domains are running, attempt to increase the limit. > ... > > There's still a lot of code here I think we can do without. > > Why do we care about the system maximum ? In the case that the system maximum is less than 132008 but greater than the current hard limit, we want to grab as many FDs as we can. I can drop it completely if you are happy that noone is really going to xenconsoled on a Linux system with nr_open less than 1M. > >> + /* >> + * Will min_fds fit within our current hard limit? >> + * (likely on *BSD, unlikely on Linux) >> + * If so, raise our soft limit. >> + */ >> + if (min_fds <= lim.rlim_max) { >> + struct rlimit new = { >> + .rlim_cur = min_fds, >> + .rlim_max = lim.rlim_max, >> + }; >> + >> + if (setrlimit(RLIMIT_NOFILE, &new) < 0) >> + syslog(LOG_WARNING, >> + "Unable to increase fd soft limit: %lu -> %u, " >> + "hard %lu (%s) - May run out with lots of domains", >> + lim.rlim_cur, min_fds, lim.rlim_max, >> + strerror(errno)); >> + } else { >> + /* >> + * Lets hope that, as a root process, we have sufficient >> + * privilege to up the hard limit. >> + */ >> + struct rlimit new = { .rlim_cur = min_fds, .rlim_max = min_fds }; >> + >> + if (setrlimit(RLIMIT_NOFILE, &new) < 0) >> + syslog(LOG_WARNING, >> + "Unable to increase fd hard limit: %lu -> %u (%s)" >> + " - May run out with lots of domains", >> + lim.rlim_max, min_fds, strerror(errno)); >> + } > This is very repetitive. The only difference between the two branches > is (a) the value of .rlim_max and (b) the log message. (b) can be > dealt with by making the log message depend only on the contents of > new. I will see what I can do. ~Andrew