Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Only one core using kernel 4.9
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Fri Jan 20, 2017 9:22 pm    Post subject: Reply with quote

Already tried 4.9.5 with the same result.

I send a bug report to the specified mailing list:
http://www.spinics.net/lists/linux-acpi/

I poked a little bit in the sources with the state i created with bisect and tried to understand what they did, with no success either.

I think i was lucky too so far. I compiled a lot of kernels since 2004 and had never such an issue.

But what's really great is the support here.
Thanks for your help and suggestions so far.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Sat Jan 21, 2017 5:59 pm    Post subject: Reply with quote

I fiddled around a little bit and added some logging.

This shows a strange thing:

[ 0.000000] DONMARTIO apicid 5
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO logical cpuids 1
[ 0.000000] DONMARTIO disabled cpus 1
[ 0.000000] DONMARTIO cpu 1
[ 0.000000] DONMARTIO apicid 6
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO logical cpuids 2
[ 0.000000] DONMARTIO disabled cpus 2
[ 0.000000] DONMARTIO cpu 2
[ 0.000000] DONMARTIO apicid 7
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO logical cpuids 3
[ 0.000000] DONMARTIO disabled cpus 3
[ 0.000000] DONMARTIO cpu 3
[ 0.000000] DONMARTIO apicid 8
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO logical cpuids 4
[ 0.000000] DONMARTIO disabled cpus 4
[ 0.000000] DONMARTIO cpu 4
[ 0.000000] DONMARTIO apicid 16
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO disabled cpus 4
[ 0.000000] DONMARTIO cpu 0
[ 0.000000] DONMARTIO apicid 17
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO logical cpuids 5
[ 0.000000] DONMARTIO disabled cpus 4
[ 0.000000] DONMARTIO cpu 5
[ 0.000000] DONMARTIO apicid 18
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO logical cpuids 6
[ 0.000000] DONMARTIO disabled cpus 4
[ 0.000000] DONMARTIO cpu 6
[ 0.000000] DONMARTIO apicid 19
[ 0.000000] DONMARTIO physical_apicid 16
[ 0.000000] DONMARTIO logical cpuids 7
[ 0.000000] DONMARTIO disabled cpus 4
[ 0.000000] DONMARTIO cpu 7


The system checks eight cpu's. The first four are disabled.

If i add this line

if(apicid < 16) return -ENODEV;

at the beginning of the function __generic_processor_info, i get all 4 cores.
(I took the 16, because i know the lowest apicid from the kernel 4.8.17 output).

I wonder if it's possible that i have an amd with eight cores labeled as quad core?

I'm really curious what's going wrong here.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
ct85711
Veteran
Veteran


Joined: 27 Sep 2005
Posts: 1696

PostPosted: Sat Jan 21, 2017 7:38 pm    Post subject: Reply with quote

Code:
I wonder if it's possible that i have an amd with eight cores labeled as quad core?


If you have an APU, that will explain why you would see 8 cores total, but only 4 you can use as the others are dedicated directly for the GPU that is built in.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Sat Jan 21, 2017 7:41 pm    Post subject: Reply with quote

donmartio wrote:
I wonder if it's possible that i have an amd with eight cores labeled as quad core?
That is indeed possible as AMD has a history of such things. When they don't have enough low end chips to satisfy demand, Intel will physically cripple higher performance chips and sell them as low performers. AMD will typically just label them as lower speed/lower core count. I think they have some way of firmware shutting off cores. The right motherboard(s) will let you turn them back on. My Athlon II X3 is really an X4 with one core shut off. The mobo says I can turn it back on, but I've never been sure it was safe.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5762

PostPosted: Sat Jan 21, 2017 8:04 pm    Post subject: Reply with quote

Tony0945 wrote:
My Athlon II X3 is really an X4 with one core shut off. The mobo says I can turn it back on, but I've never been sure it was safe.

Mine is one of those, I've been using it as an X4 for years now. I had to update the BIOS to get that, but these posts make me wonder if I could've just tweaked the kernel...
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Sun Jan 22, 2017 2:42 pm    Post subject: Reply with quote

I now have kernel-4.9.5 up and running with all four cores.
I created the following patch:

Code:
diff -urN a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
--- a/arch/x86/kernel/apic/apic.c   2017-01-20 21:12:10.000000000 +0100
+++ b/arch/x86/kernel/apic/apic.c   2017-01-22 15:06:45.058115715 +0100
@@ -2150,6 +2150,10 @@

        /* Logical cpuid 0 is reserved for BSP. */
        cpuid_to_apicid[0] = apicid;
+   } else if(!boot_cpu_detected) {
+       pr_warning("APIC: physical cpu not yet deteced. apicid is %d, physical apicid is %d.\n",
+           apicid, boot_cpu_physical_apicid);
+       return -EINVAL;
    } else {
        cpu = allocate_logical_cpuid(apicid);
        if (cpu < 0) {


and put that into /etc/portage/patches/sys-kernel/gentoo-sources-4.9.5/apic-cpu-detection.patch.
Then i remerged gentoo-sources-4.9.5, configured and compiled the kernel and now it works.

This is quiet hacky, since i don't really know if this is the right way to solve this, but it works :) .
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Sun Jan 22, 2017 4:11 pm    Post subject: Reply with quote

Absolutely! ANY look up in ANY program should deal wityh "not found".

Great detective work, donmartio.
Back to top
View user's profile Send private message
wrc1944
Advocate
Advocate


Joined: 15 Aug 2002
Posts: 3235
Location: Gainesville, Florida

PostPosted: Sun Jan 22, 2017 7:06 pm    Post subject: Reply with quote

WOW!
"Quite hacky" or not, it's still quite ingenious, and proves once again a poster's so-called "Apprentice" status doesn't mean squat.

Congrats to donmartio for resolving the mystery! And on a personal note, thanks very much. I learned a lot from following this thread. :D
_________________
Main box- AsRock x370 Gaming K4
Ryzen 1700, 3.0GHz, 16GB GSkill Flare DDR4 3200mhz
Samsung SATA 1000GB, Radeon HD R7 350 2GB DDR5
Gentoo ~amd64 plasma, glibc-2.29-r2, gcc-9.1.0 kernel-5.1.16-gentoo USE=experimental
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Wed Jan 25, 2017 9:32 am    Post subject: Reply with quote

No response so far.

Has anybody experience with filing bug reports to a kernel mailing list?
May i did something wrong or they are just to busy.

I think i could live a while with my patch but i'm also quite curious since it seems i'm the only one with this problem (what's kind of strange).
Could be a rare combination of mainboard, processor and bios.

I still wonder if i have a masked eight core under the hood.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Wed Jan 25, 2017 12:04 pm    Post subject: Reply with quote

Ant P. wrote:
Mine is one of those, I've been using it as an X4 for years now. I had to update the BIOS to get that, but these posts make me wonder if I could've just tweaked the kernel...
Rebooted, went into BIOS with DEL, clicked on "Test and unlock cores". Number of cores reported in BIOS went from 3 to 4. rebooted. lscpu shows four cores. Seems to be a bit quicker and no problems for several days now.

Seems a bit like overclocking but temps actually seem cooler.
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Wed Jan 25, 2017 12:27 pm    Post subject: Reply with quote

Hmmm, i have no 'unlock cores' or something else in my bios.
I have an ucc mode (ASRock Extreme3 970) which should unlock cores, according to the docs.
But there are no more cores if i switch this mode on.
So i suspect what the apic module detects are phantom cores.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Wed Jan 25, 2017 4:44 pm    Post subject: Reply with quote

donmartio, Ant P. and I have older Athlon II X3 CPUs. Mine is on an old AM2+ MSI mobo. I doubt if your FX- has any locked cores.
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Thu Feb 16, 2017 9:39 pm    Post subject: Reply with quote

Just for the record, i'm running the self-patched kernel 4.9.10 now. No response on my post.
I've sent the patch again. The list is pretty noisy so my post got lost, i think.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Fri Feb 17, 2017 1:00 pm    Post subject: Reply with quote

Donmartio, try filing a bug with gentoo against gentoo-sources. Then it could at least become a statndard gentoo-sources patch. Whem/if I get time I'll prepare a user patch. Or do you already have one you can share. I have not been affected by this bug, but I'll bet if I buy an early Ryzen, I will.

EDIT: DUH! You already created the patch and posted it above. It's only 7:00AM here, and I haven't had any coffee.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Fri Feb 17, 2017 1:49 pm    Post subject: Reply with quote

Patch failed for me against gentoo-sources-4.9.9. Slighly different version using diff -Naur did:
Code:
--- arch/x86/kernel/apic/apic.c.old     2017-02-17 07:29:50.207194382 -0600
+++ arch/x86/kernel/apic/apic.c 2017-02-17 07:41:04.817193931 -0600
@@ -2150,6 +2150,10 @@

                /* Logical cpuid 0 is reserved for BSP. */
                cpuid_to_apicid[0] = apicid;
+       } else if(!boot_cpu_detected) {
+                       pr_warning("APIC: physical cpu not yet detected. apicid is %d, physical apicid is %d.\n",
+               apicid, boot_cpu_physical_apicid);
+                       return -EINVAL;
        } else {
                cpu = allocate_logical_cpuid(apicid);
                if (cpu < 0) {


The logic is a bit difficult to follow with that stupid K&R layout.
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Fri Feb 17, 2017 5:24 pm    Post subject: Reply with quote

Thanks for the response Tony0945.

I got some kind of response today from one of the devs:

Code:
[+x86, Thomas and Gu Zheng]


Don't now what that means.

diff -urN works here but not for you, that's strange.
If i get that right the difference is the -a which means 'treat all files as text'.
Do you have an explanation for that ?

I hoped that i get rid of that problem with an early Ryzen :) .
I'm really curious what the apic devs find out .
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Fri Feb 17, 2017 7:38 pm    Post subject: Reply with quote

donmartio wrote:
diff -urN works here but not for you, that's strange.
If i get that right the difference is the -a which means 'treat all files as text'.
Do you have an explanation for that ?


Don't know. I got that command long ago by googling and never looked into what it meant.

Planning on an 8-core Ryzen myself and don't want the kernel to think it's a single core!
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 1775
Location: Here and Away Again

PostPosted: Fri Feb 17, 2017 10:31 pm    Post subject: €°(((>< Reply with quote

donmartio wrote:
I got some kind of response today from one of the devs:

Code:
[+x86, Thomas and Gu Zheng]


Don't now what that means.

Almost certain that it means they added those mentioned to the thread via 'cc'. :]
_________________
Kind Regards,
~ The Noob Unlimited ~

Sore wa sore, kore wa kore.
Back to top
View user's profile Send private message
wrc1944
Advocate
Advocate


Joined: 15 Aug 2002
Posts: 3235
Location: Gainesville, Florida

PostPosted: Sat Feb 18, 2017 5:24 pm    Post subject: Reply with quote

Tony0945 wrote:
Quote:
Planning on an 8-core Ryzen myself and don't want the kernel to think it's a single core!


Just noticed two new patches in the 4.9.10 patch list that seem related to zen cpus.
https://lwn.net/Articles/714592

Quote:
Borislav Petkov (1):
x86/CPU/AMD: Bring back Compute Unit ID

Yazen Ghannam (1):
x86/CPU/AMD: Fix Zen SMT topology


I hadn't realized this before, but I think this means we also need to now enable SMT in the kernel for the Zen 17h family.

IIRC, I've been not setting SMT for years as I believed amd cpus weren't using that option. AFAIK (or had thought), SMT was only relevant for Intel cpus. Am I correct on this?

BTW- 4.9.11 was just released, and I think 4.10.0 should also be out this weekend.
_________________
Main box- AsRock x370 Gaming K4
Ryzen 1700, 3.0GHz, 16GB GSkill Flare DDR4 3200mhz
Samsung SATA 1000GB, Radeon HD R7 350 2GB DDR5
Gentoo ~amd64 plasma, glibc-2.29-r2, gcc-9.1.0 kernel-5.1.16-gentoo USE=experimental
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Sat Feb 18, 2017 6:44 pm    Post subject: Reply with quote

Code:
CONFIG_SCHED_SMT:                                                                                                                                                                     │
  │                                                                                                                                                                                       │
  │ SMT scheduler support improves the CPU scheduler's decision making                                                                                                                    │
  │ when dealing with Intel Pentium 4 chips with HyperThreading at a                                                                                                                      │
  │ cost of slightly increased overhead in some places. If unsure say                                                                                                                     │
  │ N here. 
?????
I'm going to try turning it on.

Thanks for all of your Ryzen work!

EDIT: From https://en.wikipedia.org/wiki/Simultaneous_multithreading

Quote:
AMD Bulldozer microarchitecture FlexFPU and Shared L2 cache are multithreaded but integer cores in module are single threaded, so it is only a partial SMT implementation.[7]

AMD Zen microarchitecture has 2-way SMT.
Back to top
View user's profile Send private message
wrc1944
Advocate
Advocate


Joined: 15 Aug 2002
Posts: 3235
Location: Gainesville, Florida

PostPosted: Sat Feb 18, 2017 8:20 pm    Post subject: Reply with quote

I did a google seach for "amd cmt processors" and got a lot of discussions about amd CMT ((Cluster-based Multithreading), and relating to the new SMT in Zen. Got a slightly better grasp on what's going on.
One good one is:
https://forum.beyond3d.com/threads/amd-ryzen-cpu-architecture-for-2017.56187

and another one- seemingly offering a different viwpoint: http://wccftech.com/amds-high-performance-processor-cores-coming-2015-giving-modular-architecture

Tony, do you mean turning it on for non-Zen cpus, or only when you have a new Zen system? I was under the impression that SMT was "Intel hyperthreading" and not applicable to AMD CMT based cpus, but since you mention AMD has partial SMT implementation I'm still not precisely sure what all this really means. However, I am definitely becoming convinced Zen will need SMT enabled in the kernel. Guess i need to gain more knowledge on the subject. :roll:
_________________
Main box- AsRock x370 Gaming K4
Ryzen 1700, 3.0GHz, 16GB GSkill Flare DDR4 3200mhz
Samsung SATA 1000GB, Radeon HD R7 350 2GB DDR5
Gentoo ~amd64 plasma, glibc-2.29-r2, gcc-9.1.0 kernel-5.1.16-gentoo USE=experimental
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Sat Feb 18, 2017 8:34 pm    Post subject: Reply with quote

Tried that here with SMT on, but that has no effect here (as expected).

But for the ryzen, i think you are right. The commit of interest is this one:

c8cbc219d87cdbe33430b92350cb687b3f2201e6 x86/CPU/AMD: Fix Zen SMT topolog

Code:
git show c8cbc219d87cdbe33430b92350cb687b3f2201e6
commit c8cbc219d87cdbe33430b92350cb687b3f2201e6
Author: Yazen Ghannam <Yazen.Ghannam@amd.com>
Date:   Sun Feb 5 11:50:22 2017 +0100

    x86/CPU/AMD: Fix Zen SMT topology
   
    commit 08b259631b5a1d912af4832847b5642f377d9101 upstream.
   
    After:
   
      a33d331761bc ("x86/CPU/AMD: Fix Bulldozer topology")
   
    our  SMT scheduling topology for Fam17h systems is broken, because
    the ThreadId is included in the ApicId when SMT is enabled.
   
    So, without further decoding cpu_core_id is unique for each thread
    rather than the same for threads on the same core. This didn't affect
    systems with SMT disabled. Make cpu_core_id be what it is defined to be.
   
    Signed-off-by: Yazen Ghannam <Yazen.Ghannam@amd.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/20170205105022.8705-2-bp@alien8.de
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 20dc44d1e6be..2b4cf04239b6 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -319,6 +319,13 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
                if (c->x86 == 0x15)
                        c->cu_id = ebx & 0xff;
 
+               if (c->x86 >= 0x17) {
+                       c->cpu_core_id = ebx & 0xff;
+
+                       if (smp_num_siblings > 1)
+                               c->x86_max_cores /= smp_num_siblings;
+               }
+
                /*
                 * We may have multiple LLCs if L3 caches exist, so check if we
                 * have an L3 cache by looking at the L3 cache CPUID leaf.


ThreadId is included in the ApicId when SMT is enabled.

EDIT: Huh, just saw your post wrc1944, thanks for the links.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Sat Feb 18, 2017 8:45 pm    Post subject: Reply with quote

By the way, i hoped, when i read 8 cores and 16 threads, to see 16 little penguins at boot time :) .
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3086
Location: Illinois, USA

PostPosted: Sat Feb 18, 2017 9:13 pm    Post subject: Reply with quote

wrc1944 wrote:
Tony, do you mean turning it on for non-Zen cpus, or only when you have a new Zen system? I was under the impression that SMT was "Intel hyperthreading" and not applicable to AMD CMT based cpus, but since you mention AMD has partial SMT implementation I'm still not precisely sure what all this really means. However, I am definitely becoming convinced Zen will need SMT enabled in the kernel. Guess i need to gain more knowledge on the subject. :roll:
I enabled the hyperthreading kernel CONFIG on the Athlon II and as expected, it did absolutely nothing. I just rebooted the Kaveri after doing the same. The menuconfig help does indeed still say it's not applicable, but the wikipedia article indicates it might be applicable to bulldozer and later. The post just above says it might be screwed up for Fam17.

No errors or warnings in Kaveri log.


EDIT: I only enabled it on the Athlon II because this is machine I'm going to convert to Zen. I figured it would be one less thing to remember.
Back to top
View user's profile Send private message
donmartio
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 233

PostPosted: Mon Feb 20, 2017 7:48 pm    Post subject: Reply with quote

Tried kernel 4.10.0, the problem is still the same.
_________________
Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum