Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8805481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:52:44+00:00 2026-06-14T01:52:44+00:00

I am writing a small linux loadable kernel module for version 2.6.32 running on

  • 0

I am writing a small linux loadable kernel module for version 2.6.32 running on x86-64 SMP.

My question is: is there a way to obtain the offset of the address of a per-cpu variable declared in the kernel. By offset I mean the offset of the address from the percpu base, which is found in the gs register. Specifically I am trying to find the offset of the current_task variable, which is a pointer to the task-struct of the current task I believe.

I am looking at arch/x86/include/asm/current.h, which has the get_current() function. This function reads the current_task per-cpu variable using the macro percpu_read_stable. As far as I can understand percpu_read_stable basically expands into an asm routine like this:

asm("movq %%gs:%P1, %0"
  : "=r" (ret__)
  : "m" (per_cpu__current_task))

This is in arch/x86/include/asm/percpu.h.
I want to read the offset after gs from my module. If I try to simple do a printk with the per_cpu_current_task variable, the module is killed.

Thank you for your attention!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:52:45+00:00Added an answer on June 14, 2026 at 1:52 am

    Okay, I figured out the offset for this particular symbol. This one is exported by the kernel. Hence there is an entry in /proc/kallsyms

    000000000000cbc0 D per_cpu__current_task
    

    So the offset is 0xcbc0 for this particular variable. Of course the offset would vary for other versions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way of writing pexpect like small program which can launch a
I am writing a small application with Qt 4.6 (64-bit Arch Linux, though that
I'm writing some small bash scripts for copiyng certain files/directories in GNU/Linux and Solaris.
I'm writing a small sudoku game/solver in Linux using python with TUI (not GUI,
This is a small question I know. We are writing a Bash highlighter in
I am writing a small linux shell in C and am so very close
I am writing a small tool, that copies clipboard of linux into windows clip-board.
A little intro, I am currently writing a small (read tiny) RTOS kernel, well
I am writing shell script for embedded Linux in a small industrial box. I
I have a small hobby project where I'm writing a 'wrapper'-daemon in linux, in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.