From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24C09C49ED6 for ; Wed, 11 Sep 2019 19:17:27 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFA56207FC for ; Wed, 11 Sep 2019 19:17:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KPLUlTCp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFA56207FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.92.2) (envelope-from ) id 1i8871-00030I-Aq; Wed, 11 Sep 2019 15:17:07 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) (envelope-from ) id 1i886z-00030B-Ei for kernelnewbies@kernelnewbies.org; Wed, 11 Sep 2019 15:17:05 -0400 Received: by mail-pl1-x641.google.com with SMTP id k1so10577745pls.11 for ; Wed, 11 Sep 2019 12:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gcTkbJek5KVQuy5LYkDQhrWWvb/1srNxgvcZKu2Ffuw=; b=KPLUlTCpsG44bdAeqX2bSwC+uagEkEvOPjPOBFvuOBTAS4WpxVlaMLe6rAuutZjuEj JF5342x9Jz7uwAqS7pLOCvTXVtnD8ART6WcDvjjhMFXrtwGhYIZVRPLkpLvQC98WeQ9s gx1SXgJgr/DAtAIzAlu8yb8gUGo+72wmm7Xv3RGtE4cIaUm2TqBmiz+MHCn+ySsV7GuO +tCUF+u1g2eH7hSP4CusY4txDJbHkrCM6cIGcNzoAp16xF1a6N/pyby2zri92ugEKRav nDFIqEhbzDKMVLcA8c/q69M+/gfhM2c6wnk1ma8PtgwyZ2XGzI5L96z8qBlfyYbjWvB4 2UYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=gcTkbJek5KVQuy5LYkDQhrWWvb/1srNxgvcZKu2Ffuw=; b=hciY8+iMpxMfAQDB7p0oCd7pB2yE0n0hbLh2Fz3DUFW6btaf+s2j5kJOrIR7E3vG/m 1jZfDsxdtonJDcqGkYRV7Ohdiv8exdlR59QfB8wiNvAXK9XW0021eOnQZWt2fsTQKL+D hNh6fBDBxR0FElv1DZh0TFCGFk9S5W7WGEd8l3N8qcurW6kY/ev72iFc3mrQr30Yprn7 zbNsiVhoNGENNAfIDsFBBwHyYN+LdVoKovG7cJWz8suPICYkDtNiqfBr0a6AiFj6MUKT x4ObXXt9O9S69CeGJn8XWSHYkriFFPqUySv7iQcvdJSiLwDhjcoxkytV2GbJzQSz3vn4 hQNQ== X-Gm-Message-State: APjAAAVfQ20jCBke2/48qwhko3924KJ++PidERCeKKoUfuGUOFWxEJAA /rRuCwKJsIYG9r3pbRCpgsE= X-Google-Smtp-Source: APXvYqzJtvViY7DKSAIY9rLk70U97yoM9F40jv1oaje+CjDfZgF4N7dIPboHc+nqX0zNnZtZL5FnmQ== X-Received: by 2002:a17:902:b115:: with SMTP id q21mr39619208plr.241.1568229422739; Wed, 11 Sep 2019 12:17:02 -0700 (PDT) Received: from bharath12345-Inspiron-5559 ([103.110.42.34]) by smtp.gmail.com with ESMTPSA id f14sm33040582pfq.187.2019.09.11.12.17.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Sep 2019 12:17:01 -0700 (PDT) Date: Thu, 12 Sep 2019 00:46:57 +0530 From: Bharath Vedartham To: Martin Galvan Subject: Re: Setting CPU affinity for current process on kernel module? Message-ID: <20190911191657.GA11969@bharath12345-Inspiron-5559> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Wed, Sep 11, 2019 at 03:52:06PM -0300, Martin Galvan wrote: > Hi, > > I have a kernel module which needs to perform CPU core-specific > operations. I know that there's a kernel mode version of > sched_setaffinity, however it's not exported to modules and can only > be accessed through e.g. kallsyms_lookup_name, which is ugly. The > alternative is to spawn a new kthread and bind it to the desired CPU > before starting it, but I was wondering if there's a more > straightforward method of doing this. Thanks! > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies So one thing that pops to my head is using cgroups. Create a cgroup, modify the cpu file in cpusets cgroup and add the required task to it. But I am not sure whether you can do all of this from a kernel module... Thanks Bharath _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies