Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for virtualized (xen) platforms (i.e. amazon ec2) #33

Merged
merged 3 commits into from

3 participants

@mpokrywka

Prevent problems similar to issue 316
[31029.489919] ***************************************************************
[31029.489922] ***************************************************************
[31029.489924] ** WARNING: Currently emulating unsupported memory accesses **
[31029.489927] ** in /lib/tls glibc libraries. The emulation is **
[31029.489930] ** slow. To ensure full performance you should **
[31029.489932] ** install a 'xen-friendly' (nosegneg) version of **
[31029.489935] ** the library, or disable tls support by executing **
[31029.489937] ** the following as root: **
[31029.489940] ** mv /lib/tls /lib/tls.disabled **
[31029.489942] ** Offending process: zzzzzzzz (pid=16229) **
[31029.489945] ***************************************************************
[31029.489947] ***************************************************************

@FooBarWidget

Thanks for this patch. However I read this from http://cs.felk.cvut.cz/~vaclam1/linux/ucebna/k310/data/doc/howto-xen-and-gentoo-en.html:

"Some software, in particular the glibc TLS library, is implemented in a way that will conflict with how Xen uses segment registers to circumvent a limitation of 32-bit x86 hardware platforms, causing poor performance whilst carrying out certain operations under Xen. This will result in a ~50% performance penalty running multi-threaded applications. To fix this, you must compile your system with the '-mno-tls-direct-seg-refs' flag."

So this flag is only required on x86? You should add an extra check so that this flag is only enabled for x86 systems.

And before we can merge your changes we need you to sign the contributor agreement at http://www.phusion.nl/forms/contributor_agreement
Could you follow the instructions there?

@mpokrywka

Added check to require option only on 32bit x86 Xen hosts
32ba4e2
Contributor agreement signed

@FooBarWidget

You should check for the file first and then cpu_architectures because checking for the file is the most inexpensive operation.

@mpokrywka

Added 0a5f1b0
but I think "supports_sfence_instruction?" called by "portability_cflags" already memoized "cpu_architectures".

@FooBarWidget FooBarWidget merged commit 054d106 into from
@FooBarWidget

Thanks, I've merged it now.

@vemind

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 24, 2011
  1. @mpokrywka
Commits on Nov 25, 2011
  1. @mpokrywka
Commits on Nov 26, 2011
  1. @mpokrywka
This page is out of date. Refresh to see the latest.
View
1  build/config.rb
@@ -35,6 +35,7 @@
# Should be included last in the command string, even after PlatformInfo.portability_cflags.
EXTRA_CXXFLAGS = "-Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long"
EXTRA_CXXFLAGS << " -Wno-missing-field-initializers" if PlatformInfo.compiler_supports_wno_missing_field_initializers_flag?
+EXTRA_CXXFLAGS << " -mno-tls-direct-seg-refs" if PlatformInfo.requires_no_tls_direct_seg_refs? && PlatformInfo.compiler_supports_no_tls_direct_seg_refs_option?
EXTRA_CXXFLAGS << " #{OPTIMIZATION_FLAGS}" if !OPTIMIZATION_FLAGS.empty?
# Extra linker flags that should always be passed to the linker.
View
5 lib/phusion_passenger/platform_info/compiler.rb
@@ -66,6 +66,11 @@ def self.compiler_supports_wno_missing_field_initializers_flag?
end
memoize :compiler_supports_wno_missing_field_initializers_flag?
+ def self.compiler_supports_no_tls_direct_seg_refs_option?
+ return try_compile(:c, '', '-mno-tls-direct-seg-refs')
+ end
+ memoize :compiler_supports_no_tls_direct_seg_refs_option?, true
+
# Returns whether compiling C++ with -fvisibility=hidden might result
# in tons of useless warnings, like this:
# http://code.google.com/p/phusion-passenger/issues/detail?id=526
View
5 lib/phusion_passenger/platform_info/operating_system.rb
@@ -153,6 +153,11 @@ def self.supports_lfence_instruction?
}))
end
memoize :supports_lfence_instruction?, true
+
+ def self.requires_no_tls_direct_seg_refs?
+ return File.exists?("/proc/xen/capabilities") && cpu_architectures[0] == "x86"
+ end
+ memoize :requires_no_tls_direct_seg_refs?, true
end
end # module PhusionPassenger
Something went wrong with that request. Please try again.