can a regular file ./proc/cpuinfo containing the correct info fool it? I'd think fopen won't care if the file is on real fs or not.<br><br><div class="gmail_quote">2008/4/1 Jeff Lightner <<a href="mailto:jlightner@water.com">jlightner@water.com</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div link="blue" vlink="blue" style="" lang="EN-US">
<div>
<div>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">I guess I should have mentioned the OP on
the BIND list specifically stated that using "-n 4" still only
resulted in BIND finding 1 CPU.</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Later discussion on the BIND list (after I'd
posted here) indicates:</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;">After quick look into bind
and glibc code /proc has to be mounted.</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;">named calls sysconf(3)
function and internal glibc implementation looks like this:</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> </span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;">__get_nprocs () {</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;">..</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> FILE *fp = fopen
("/proc/stat", "rc");</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> if (fp != NULL) {</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> ..</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> } else {</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> fp =
fopen ("/proc/cpuinfo", "rc");</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> if (fp !=
NULL) {</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;">
..</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> }</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> ..</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> }</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> </span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> return 1;</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;">}</span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;"> </span></font></p>
<p style=""><font face="Courier New" size="2"><span style="font-size: 10pt;">So if you don't have /proc
mounted in chroot glibc is not able to get number of CPUs and returns 1. When
you don't need detect correct number of CPUs (always use one CPU) then you
don't have to mount /proc</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">The poster was from RedHat and in a later
post indicated he was going to work on a patch to determine number of CPUs
BEFORE BIND starts the chroot environment as suggested in response to the
above.</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">That seems to sum it up nicely for me.</span></font></p>
<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>
<div>
<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">
<hr align="center" size="2" width="100%">
</span></font></div>
<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;">
<a href="mailto:ale-bounces@ale.org" target="_blank">ale-bounces@ale.org</a> [mailto:<a href="mailto:ale-bounces@ale.org" target="_blank">ale-bounces@ale.org</a>] <b><span style="font-weight: bold;">On Behalf Of </span></b>Jason Fritcher<br>
<b><span style="font-weight: bold;">Sent:</span></b> Tuesday, April 01, 2008 2:20
PM<br>
<b><span style="font-weight: bold;">To:</span></b> <a href="mailto:ale@ale.org" target="_blank">ale@ale.org</a><br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [ale] chroot and
/proc?</span></font></p>
</div><div><div></div><div class="Wj3C7c">
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On Apr 1, 2008, at 12:09 PM, Jeff Lightner wrote:</span></font></p>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;" type="cite">
<div>
<div>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Alternatively
I'm wondering if there isn't a better way to let the chroot
environment BIND know that there are 4 CPUs?</span></font></p>
</div>
</div>
</blockquote>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Sure, there is a command-line option to tell it how many CPUs there
are...</span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</div>
<div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> -n #cpus</span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> Create #cpus worker threads to
take advantage of multiple CPUs. If</span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> not specified, named will try
to determine the number of CPUs</span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> present and create one thread
per CPU. If it is unable to determine</span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> the number of CPUs, a single
worker thread will be created.</span></font></p>
</div>
<div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</div>
</div>
</div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">-- </span></font></p>
<span style="word-spacing: 0px;">
<div>
<div style="">
<div>
<p><font color="black" face="Helvetica" size="1"><span style="font-size: 9pt; font-family: Helvetica; color: black;">Jason Fritcher</span></font></p>
</div>
<div>
<p><font color="black" face="Helvetica" size="1"><span style="font-size: 9pt; font-family: Helvetica; color: black;"><a href="mailto:jkf@wolfnet.org" target="_blank">jkf@wolfnet.org</a></span></font></p>
</div>
<div>
<p><font color="black" face="Helvetica" size="1"><span style="font-size: 9pt; font-family: Helvetica; color: black;"> </span></font></p>
</div>
</div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"></span> </font></p></div></span>
</div></div></div>
<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;"> </span></font></p>
</div>
</div><div><div></div><div class="Wj3C7c">
<div style="font-size: 9pt; font-family: Courier New;">
<font face="Arial" size="2">----------------------------------<br>CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.<br>
----------------------------------<br></font>
</div>
</div></div><br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
<br></blockquote></div><br>