Re: Seeking Assistance with Spin Lock Usage and Resolving Hard LOCKUP Error

2024-05-17 Thread jim . cromie
On Thu, May 9, 2024 at 8:39 AM Muni Sekhar  wrote:
>
> Dear Linux Kernel Community,
>
> I am reaching out to seek assistance regarding the usage of spin locks
> in the Linux kernel and to address a recurring issue related to hard
> LOCKUP errors that I have encountered during testing.
>

build your kernel with LOCKDEP everything ?


> Recently, I developed a small kernel module that involves ISR handling
> and utilizes the spinlock_t primitive. In my module, I have employed
> spin locks both in process context using spin_lock() and spin_unlock()
> APIs, as well as in ISR context using spin_lock_irqsave() and
> spin_unlock_irqrestore() APIs.
>
> Here is a brief overview of how I have implemented spin locks in my module:
>

I certainly dont know whether the above and below are legal.
Id be comparing my usage to working examples from the source-code.

and you didnt say anything about your module or what it does.
(fwiw, you'd get more help if it were "our" module, ie gpl'd)



> However, during testing, I have encountered a scenario where a hard
> LOCKUP (NMI watchdog: Watchdog detected hard LOCKUP on cpu 2) error
> occurs, specifically when a process context code execution triggers
> the spin_lock() function and is preempted by an interrupt that enters
> the ISR context and encounters the spin_lock_irqsave() function. This
> situation leads to the CPU being stuck indefinitely.
>

Id build w/o watchdog, to see what else goes wrong.
2 different errors might help find common cause.



> My primary concern is to understand the appropriate usage of spin
> locks in both process and ISR contexts to avoid such hard LOCKUP
> errors. I am seeking clarification on the following points:
>

Documentation/locking/hwspinlock.rst

> Is it safe to use spin_lock_irqsave() and spin_unlock_irqrestore()
> APIs in ISR context and spin_lock() and spin_unlock() APIs in process
> context simultaneously?
> In scenarios where a process context code execution is preempted
> by an interrupt and enters ISR context, how should spin locks be used
> to prevent hard LOCKUP errors?
> Are there any specific guidelines or best practices for using spin
> locks in scenarios involving both process and ISR contexts?
>
> I would greatly appreciate any insights, guidance, or suggestions from
> the experienced members of the Linux kernel community to help address
> this issue and ensure the correct and efficient usage of spin locks in
> my kernel module.
>
> Thank you very much for your time and assistance.
>
> --
> Thanks,
> Sekhar
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Handling I2C eeprom devices

2024-05-17 Thread jim . cromie
On Fri, May 17, 2024 at 7:35 AM Patryk  wrote:
>
> Hi,
> I've got a question regarding how to handle I2C eeprom devices. I see
> that in the kernel/drivers/misc/eeprom there are not that many drivers
> available. Does it mean that they support various chips that do not
> necessarily come from one vendor?
> Looking at example at24.c, in the compatible properties I see that all
> of them refers to atmel, however when I compared the following
> devices: AT24C04C and BRCB008GWZ, at the first glance they look kinda
> similar:
> - they are organized internally in the same way - 1024 x 8 (8K)
> - read/write commands looks the same
>
> I'm not asking you to tell me whether or not it's possible this driver
> at24 with the device I need (BRCB008GWZ), rather I would like to get a
> suggestion on how to approach this and what factors I should take into
> account to make the right decision.
>
> Best regards
> Patryk
>

$ git ls-files | grep eprom | wc -l
89
[jimc@frodo linux.git]$ git ls-files | grep eprom\.h | wc -l
29
[jimc@frodo linux.git]$ git ls-files | grep eprom  | grep include
arch/parisc/include/asm/eisa_eeprom.h
arch/sparc/include/asm/eeprom.h
drivers/staging/rtl8723bs/include/rtw_eeprom.h
include/linux/eeprom_93cx6.h
include/linux/eeprom_93xx46.h
include/linux/spi/eeprom.h
include/media/tveeprom.h

Id look at those headers for similarity,
then the 2 c files in misc for similarity.

also the files under devicetree - thats ALL interface defn

you didnt say if those parts are I2C or SPI or what.

do you have the hardware ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


git send-email and gmail smtp

2024-04-17 Thread jim . cromie
so I tried to submit a patchset via sendemail,
and ran aground on authorization.

its been a while since I sent from this computer,
laptop power cord is cut :-(
but failure wording is ambiguous

5.7.8 Username and Password not accepted. For more information, go to
5.7.8  https://support.google.com/mail/?p=BadCredentials
j15-20020a0566022ccf00b007d6905cc017sm3758492iow.4 - gsmtp

Essentially, google is changing policy,
and 2FA is coming (or just arrived)

is there a well-travelled path to work around this issue?

something like ssh-key-agent ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux 4 block device driver infrastructure

2023-12-07 Thread jim . cromie
On Thu, Nov 30, 2023 at 9:08 AM Alexandru Goia
 wrote:
>
> Greetings !
>
> I am a Unix/Linux hobbyist from Romania, interested in kernel stuff.
> I need some clarifications, related to block device subsystem in Linux 4,
> so I will ask them here, if you can answer me, please...
>
> 1) Why (in Linux 4) in struct block_device_operations, the (*open)(struct 
> block_device *, fmode_t)
> has a different signature than the (*release)(struct gendisk *, fmode_t) ? 
> Why open()
> uses block_device, while release() uses gendisk ? They are both in a struct
> block_device_operations. Why they not refer to the same thing ?
>

in linux current, its not like that:

struct block_device_operations {
void (*submit_bio)(struct bio *bio);
int (*poll_bio)(struct bio *bio, struct io_comp_batch *iob,
unsigned int flags);
int (*open)(struct gendisk *disk, blk_mode_t mode);
void (*release)(struct gendisk *disk);

Old books are still useful, but new code is a much better place to look.



> I understand that gendisk refer to a real disk, and block_device (s) to 
> logical disk (s)
> and partitions. But why the kernel developers have chosen to use different 
> signatures ?
>
> 2) Release() is also synonim to close() ?
> 3) Why is not explicitely present a close() function ?
> 4) Why struct gendisk does not have inside it pointers to struct block_device 
> ?
>
> Thank you very much,
> Alexander,
> Computer hobbyist,
> Romania
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: from CoLinux to MoreLinux :D

2023-12-07 Thread jim . cromie
On Mon, Dec 4, 2023 at 1:02 PM Mario Marietto  wrote:
>
> What is this ?
>
> https://l4re.org/download/snapshots/pre-built-images/arm-v7/
>

Thats a micro-kernel, sort of like GNU Hurd.

theres also
https://doc.redox-os.org/book/ch04-01-microkernels.html

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: What situation will an anonymous writer come?

2023-11-10 Thread jim . cromie
On Tue, Nov 7, 2023 at 2:01 AM  wrote:
>
> Hi,
>
> I find this function __up_writer refering to an anonymous a writer? How does 
> it occur?
> ```
> // kernel/locking/rwsem.c
> static inline void __up_write(struct rw_semaphore *sem)
> {
> long tmp;
>
> DEBUG_RWSEMS_WARN_ON(sem->magic != sem, sem);
> /*
>  * sem->owner may differ from current if the ownership is transferred
>  * to an anonymous writer by setting the RWSEM_NONSPINNABLE bits.
>  */
> DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) &&
> !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE), 
> sem);<--  is it necessary?
>
> preempt_disable();
> rwsem_clear_owner(sem);
> tmp = atomic_long_fetch_add_release(-RWSEM_WRITER_LOCKED, 
> >count);
> if (unlikely(tmp & RWSEM_FLAG_WAITERS))
> rwsem_wake(sem);
> preempt_enable();
> }
> ```
>
> I do a search by using `git blame` and find it's added in this commit 
> 02f1082b003a0cd48f48f12533d969cdbf1c2b63,
> and in this commit d7d760efad70c7a030725499bf9f342f04af24dd, it refers to 
> below situation that can have an anonymous writer:
>
> > There are use cases where a rwsem can be acquired by one task, but
> > released by another task. In thess cases, optimistic spinning may need
> > to be disabled. One example will be the filesystem freeze/thaw code
> > where the task that freezes the filesystem will acquire a write lock
> > on a rwsem and then un-owns it before returning to userspace. Later on,
> > another task will come along, acquire the ownership, thaw the filesystem
> > and release the rwsem.
> >
> > Bit 0 of the owner field was used to designate that it is a reader
> > owned rwsem. It is now repurposed to mean that the owner of the rwsem
> > is not known. If only bit 0 is set, the rwsem is reader owned. If bit
> > 0 and other bits are set, it is writer owned with an unknown owner.
> > One such value for the latter case is (-1L). So we can set owner to 1 for
> > reader-owned, -1 for writer-owned. The owner is unknown in both cases.
> >
> > To handle transfer of rwsem ownership, the higher level code should
> > set the owner field to -1 to indicate a write-locked rwsem with unknown
> > owner. Optimistic spinning will be disabled in this case.
> >
> > Once the higher level code figures who the new owner is, it can then
> > set the owner field accordingly.
>
> As it mentions that at higher level, we set -1 to owner subjectively in order 
> to do an owner migration, and I only find it's used in only
> one place, i.e. percpu-rwsem in this commit 
> 5a817641f68a6399a5fac8b7d2da67a73698ffed which has been removed in commit
> 7f26482a872c36b2ee87ea95b9dcd96e3d5805df.
>
> So does it mean an anonymous writer don't exist at current kernel? should we 
> remove the second condition in this assert check?
>
> DEBUG_RWSEMS_WARN_ON((rwsem_owner(sem) != current) &&
> !rwsem_test_oflags(sem, RWSEM_NONSPINNABLE), sem);
>
> Thanks,
> Mu

you didnt really say why youre looking at it.
I presume youve triggered an error that implied it was your prob,
and removing the 2nd condition fixed it ?

If so (and you get no further "advice" here)
I would try feeding it to lkp-robot, it will at least build-test it
on "all" the arches you dont have at hand.

FWIW, there are ~12 uses of that macro, and only 1 has the 2nd condition.
Were they all added together, or were they spread across several commits ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


how to use perf record effectively

2023-11-10 Thread jim . cromie
I have a working patchset which de-duplicates the pr_debug
per-callsite ( module, filename, function ) data.

it loads that column data into 3 maple-trees,
and simple accessor fns retrieve the data
by lookup with the pr-debug address.

So it stores these callsites:
[0.721980] dyndbg: 3653 prdebugs in 307 modules, 19 KiB in ddebug
tables, 114 kiB ..

into these intervals:
[  104.047210] dyndbg: mt-funcs has 2174 entries
[  104.047816] dyndbg: mt-files has 539 entries
[  104.048410] dyndbg: mt-mods has 312 entries

once these are loaded, the __dyndbg_sites section,
which separates the 3 columns from the __dyndbg section,
can be recycled.contains

ALL GOOD SO FAR.
BUT WHATS THE RUNTIME COST OF THIS ?

perf stat -r200 cat /proc/dynamic_debug/control > /dev/null;

this should be a good test - it calls all 3 accessors for each
pr-debug in the kernel.

but comparing master against this branch shows little change,
and adding --table to see the variations in the runs
suggests that the change is less than the variation within a test.

MASTER - v6.6

bash-5.2# perf stat -r 200 cat /proc/dynamic_debug/control > /dev/null

 Performance counter stats for 'cat /proc/dynamic_debug/control' (200 runs):

 10.29 msec task-clock   #0.713
CPUs utilized   ( +-  0.56% )
43  context-switches #4.177
K/sec   ( +-  0.03% )
 1  cpu-migrations   #   97.142
/sec( +-  5.80% )
73  page-faults  #7.091
K/sec   ( +-  0.10% )
   8906200  cycles   #0.865
GHz ( +-  0.17% )
147349  stalled-cycles-frontend  #1.65%
frontend cycles idle( +-  0.18% )
 24971  stalled-cycles-backend   #0.28%
backend cycles idle ( +-  8.18% )
  20589718  instructions #2.31
insn per cycle
  #0.01  stalled
cycles per insn ( +-  0.02% )
   5470202  branches #  531.388
M/sec   ( +-  0.01% )
 0  branch-misses

 0.0144421 +- 0.647 seconds time elapsed  ( +-  0.45% )


DE_DUPLICATION branch

bash-5.2# perf stat -r200 cat /proc/dynamic_debug/control > /dev/null

 Performance counter stats for 'cat /proc/dynamic_debug/control' (200 runs):

 21.89 msec task-clock   #0.622
CPUs utilized   ( +-  0.69% )
44  context-switches #2.010
K/sec   ( +-  0.12% )
 1  cpu-migrations   #   45.693
/sec( +-  3.87% )
73  page-faults  #3.336
K/sec   ( +-  0.10% )
  52017542  cycles   #2.377
GHz ( +-  0.54% )
177875  stalled-cycles-frontend  #0.34%
frontend cycles idle( +-  0.48% )
134469  stalled-cycles-backend   #0.26%
backend cycles idle ( +-  4.24% )
 134707837  instructions #2.59
insn per cycle
  #0.00  stalled
cycles per insn ( +-  0.30% )
  39386555  branches #1.800
G/sec   ( +-  0.29% )
 0  branch-misses

  0.035188 +- 0.000167 seconds time elapsed  ( +-  0.47% )



I tried perf stat record, then perf-diff on the results,
it showed empty comparisons on a handful of event-types

[jimc@frodo boots-dump]$ perf diff -v
v6.6-36-g73a29cb216c0/perf-rec-6.6.0-f2-00036-g73a29cb216c0*
v6.6-8-g067d1f1d8675/perf-rec-6.6.0-tf2-8-g067d1f1d8675*
v6.6-23-g10f95252e906/perf-rec-6.6.0-tf2-00023-g10f95252e906* > foo
group desc not available
pmu capabilities not available
group desc not available
pmu capabilities not available
group desc not available
pmu capabilities not available
group desc not available
pmu capabilities not available
group desc not available
pmu capabilities not available
group desc not available
pmu capabilities not available
group desc not available
pmu capabilities not available
[jimc@frodo boots-dump]$ more foo
# Event 'task-clock'
#
# Data files:
#  [0] v6.6-36-g73a29cb216c0/perf-rec-6.6.0-f2-00036-g73a29cb216c0 (Baseline)
#  [1] v6.6-36-g73a29cb216c0/perf-rec-6.6.0-f2-00036-g73a29cb216c0-null
#  [2] v6.6-8-g067d1f1d8675/perf-rec-6.6.0-tf2-8-g067d1f1d8675
#  [3] v6.6-8-g067d1f1d8675/perf-rec-6.6.0-tf2-8-g067d1f1d8675-null
#  [4] v6.6-23-g10f95252e906/perf-rec-6.6.0-tf2-00023-g10f95252e906
#  [5] v6.6-23-g10f95252e906/perf-rec-6.6.0-tf2-00023-g10f95252e906-null
#
# Baseline/0  Delta Abs/1  

Re: How to switch driver from wireless extension to cfg/mac80211

2023-10-13 Thread jim . cromie
On Sat, Oct 7, 2023 at 1:14 PM Philipp Hortmann
 wrote:
>
> Hi,
>
> after cutting away a lot of dead code from the rtl8192e I would like to
> understand the way forward to migrate the driver from wireless extension
> to cfg/mac80211.
>

I think you need more email recipients for definitive answers.
In particular, is anyone else doing this ?
if they are, you should find them, make the job easier.

> What is the best way forward to migrate the driver rtl8192e towards the
> drivers/net/wireless/realtek/rtlwifi/rtl8192* ?
>

Id start with this search:
$ git log --grep=ieee80211_ -p -- drivers/net/wireless/realtek/ | less
+/ieee80211_

then narrow with a particular api-call that sounds like it would be central
to the switchover.

It might be useful to search for many api calls at once,
rank them by how many of the calls they add
(presuming more to be better, more "comprehensive")


> Does it have to be a hard cut?

not sure what you mean, but I'd guess no - smaller incremental changes
are preferred

>
> What to start with?
>   - start to change the used structs towards ieee80211_hw?

the old adage:  look at the data structs 1st.
not sure how well that applies in any given (or your) situation.

adapting old code to new structs does sound sane, and incrementally testable.

>
> Thanks for your support.
>
> Bye Philipp
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


help - macro arg reuse - fix ?

2023-10-13 Thread jim . cromie
is there a simple fix for this ?


-:451: CHECK:MACRO_ARG_REUSE: Macro argument reuse '_var' - possible
side-effects?
#451: FILE: include/linux/dynamic_debug.h:121:
+#define DYNDBG_CLASSMAP_USE_(_var, _uname) \
+   extern struct ddebug_class_map _var;\
+   static struct ddebug_class_user __aligned(8) __used \
+   __section("__dyndbg_class_users") _uname = {\
+   .user_mod_name = KBUILD_MODNAME,\
+   .map = &_var,   \
}

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


how to fix MACRO_ARG_REUSE

2023-08-23 Thread jim . cromie
on a recent submit to LKML
https://lore.kernel.org/lkml/20230801170255.163237-1-jim.cro...@gmail.com/

I got a Patchwork CI warning in report:
https://patchwork.freedesktop.org/series/113363/


1a864a4fe7ce dyndbg-API: fix CONFIG_DRM_USE_DYNAMIC_DEBUG regression

-:445: CHECK:MACRO_ARG_REUSE: Macro argument reuse '_var' - possible
side-effects?
#445: FILE: include/linux/dynamic_debug.h:120:
+#define DYNDBG_CLASSMAP_USE_(_var, _uname) \
+extern struct ddebug_class_map _var; \
+struct ddebug_class_user __used \
+__section("__dyndbg_class_users") _uname = { \
+  .user_mod_name = KBUILD_MODNAME, \
+  .map = &_var, \
  }

_var is expanded 2x, the "extra" time is to declare it as "extern",
meaning its exported elsewhere.

the usual fix for macro problems like this is __typeof();
something like:
#define foo(a,b,...) \
  typeof(a) _a = a; \
  ...

but I dont see how to use it -
I need _var to name the struct exported from another module,
and I need to take its &-address.

Is there a trick / technique I can use ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


back at the naming bikeshed

2023-07-14 Thread jim . cromie
so I found myself writing this macro, and using it 4 times.

+#define for_each_boxed_veclen(_box, _vec, _len, _ct, _curs) \
+ for (_ct = 0, _curs = _box->_vec; _ct < _box->_len; _ct++, _curs++)

- for (i = 0, cm = di->classes; i < di->num_classes; i++, cm++) {
+ for_each_boxed_veclen(di, classes, num_classes, i, cm) {

Qs:

does it exist by another name already ?

is it worth having generally ?

are there better ways to do it ?

fwiw, it does sound semantically connected to __counted_by()  attribute

struct Ntuple {
  int len;
  struct tuple **vector __counted_by(len);
}

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: CONFLICT (content): Merge conflict in scripts/kconfig/Makefile

2023-07-05 Thread jim . cromie
On Fri, Jun 23, 2023 at 12:15 PM Mario Marietto  wrote:
>
> Hello.
>
> I'm trying to enable KVM virtualization on the Arm Chromebook using KVM-tool. 
> This is the tutorial where I'm reading how to do that :
>
>
> https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/virtualization-on-the-chromebook-using-kvm-tool
>
>
> Below you can see what I did and the error that I've got :
>
>
> /home/marietto/Scrivania/Chromebook# git clone 
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
>
> Cloning into 'linux-stable'...
> remote: Enumerating objects: 11487511, done.
> remote: Counting objects: 100% (3953/3953), done.
> remote: Compressing objects: 100% (2263/2263), done.
> remote: Total 11487511 (delta 2912), reused 2100 (delta 1686), pack-reused 
> 11483558
> Ricezione degli oggetti: 100% (11487511/11487511), 4.47 GiB | 6.32 MiB/s, 
> done.
> Risoluzione dei delta: 100% (9170170/9170170), done.
> Checking out files: 100% (80340/80340), done.
>
> /home/marietto/Scrivania/Chromebook# cd linux-stable
>
> /home/marietto/Scrivania/Chromebook/linux-stable# git checkout
>
> Your branch is up to date with 'origin/master'.
>
> /home/marietto/Scrivania/Chromebook/linux-stable# git checkout 
> origin/linux-5.4.y -b linux-5.4.y
>
> Checking out files: 100% (72207/72207), done.
> Branch 'linux-5.4.y' set up to track remote branch 'linux-5.4.y' from 
> 'origin'.
> Switched to a new branch 'linux-5.4.y'
>
> /home/marietto/Scrivania/Chromebook/linux-stable# git remote add kvm-tool 
> https://github.com/penberg/linux-kvm.git
>
>
> /home/marietto/Scrivania/Chromebook/linux-stable# git remote update
>
> Fetching origin
> Fetching kvm-tool
> remote: Enumerating objects: 11257, done.
> remote: Counting objects: 100% (676/676), done.
> remote: Total 11257 (delta 675), reused 675 (delta 675), pack-reused 10581
> Ricezione degli oggetti: 100% (11257/11257), 2.57 MiB | 8.98 MiB/s, done.
> Risoluzione dei delta: 100% (7441/7441), completed with 36 local objects.
> Da https://github.com/penberg/linux-kvm
>  * [nuovo branch]  master -> kvm-tool/master
>  * [nuovo branch]  vga/core   -> kvm-tool/vga/core
>
> /home/marietto/Scrivania/Chromebook/linux-stable# git merge kvm-tool/master
>
> Auto-merging scripts/kconfig/Makefile
> CONFLICT (content): Merge conflict in scripts/kconfig/Makefile
> Auto-merging arch/x86/Kconfig
> Auto-merging MAINTAINERS
> CONFLICT (content): Merge conflict in MAINTAINERS
> warning: inexact rename detection was skipped due to too many files.
> warning: you may want to set your merge.renamelimit variable to at least 
> 30049 and retry the command.
> Automatic Merge failed; fix the conflicts and run the commit of the result.
>
> # git merge kvm-tool/master
>
> error: Merging is not possible because you have unmerged files.
> hint: Fix them up in the work tree, and then use 'git add/rm '
> hint: as appropriate to mark resolution and make a commit.
> fatal: Exiting because of an unresolved conflict.
>
>
> this is the conflict I see inside the Makefile :
>
>
> <<< HEAD
> PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig 
> build_menuconfig build_nconfig build_gconfig build_xconfig
> PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig 
> update-po-config localmodconfig localyesconfig kvmconfig
> >>> kvm-tool/master
>
>
> Is there a chance to fix it ? thanks
>

of course there is.  you must decide.

offhand - Id try to just combine the 2 lists into 1,
duplicates are probly ok in PHONY targets.
then drop as errs/suggestions guide

>


> --
> Mario.
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [jimc:dd-fix-2g] BUILD REGRESSION 664531695395972a1684dbc3604731db280b479e

2023-06-14 Thread jim . cromie
On Tue, Jun 13, 2023 at 11:43 AM  wrote:
>
> Trouble with __UNIQUE_ID
>
> Im getting an error which "shouldnt be possible", but is happening anyway.
>
>
> On Mon, Jun 12, 2023 at 2:55 PM kernel test robot  wrote:
> >
> > hppa-linux-ld: 
> > drivers/gpu/drm/nouveau/nouveau_drm.o:(__dyndbg_class_users+0x0): multiple 
> > definition of `__UNIQUE_ID_ddebug_class_user323'; 
> > drivers/gpu/drm/radeon/radeon_drv.o:(__dyndbg_class_users+0x0): first 
> > defined here

> > riscv64-linux-ld: drivers/gpu/drm/gud/gud_drv.o:(__dyndbg_class_users+0x0): 
> > multiple definition of `__UNIQUE_ID_ddebug_class_user305'; 
> > drivers/gpu/drm/qxl/qxl_drv.o:(__dyndbg_class_users+0x0): first defined here
> > riscv64-linux-ld: 
> > drivers/gpu/drm/nouveau/nouveau_drm.o:(__dyndbg_class_users+0x0): multiple 
> > definition of `__UNIQUE_ID_ddebug_class_user374'; 
> > drivers/gpu/drm/radeon/radeon_drv.o:(__dyndbg_class_users+0x0): first 
> > defined here
> >
> > Error/Warning ids grouped by kconfigs:
> >
> > gcc_recent_errors
> > |-- parisc-allyesconfig
> > |   `-- 
> > multiple-definition-of-__UNIQUE_ID_ddebug_class_user323-drivers-gpu-drm-radeon-radeon_drv.o:(__dyndbg_class_users):first-defined-here
> > |-- riscv-allyesconfig
> > |   |-- 
> > multiple-definition-of-__UNIQUE_ID_ddebug_class_user305-drivers-gpu-drm-qxl-qxl_drv.o:(__dyndbg_class_users):first-defined-here
> > |   `-- 
> > multiple-definition-of-__UNIQUE_ID_ddebug_class_user374-drivers-gpu-drm-radeon-radeon_drv.o:(__dyndbg_class_users):first-defined-here
>
> the source of the error is this:
>
> /**
>  * DYNDBG_CLASSMAP_USE - refer to a classmap, DEFINEd elsewhere.
>  * @_var: name of the exported classmap var
>  *
>  * This registers a module's use of another module's classmap defn, so
>  * dyndbg can authorize "class DRM_CORE ..." >control commands upon
>  * this module.
>  */
> #define DYNDBG_CLASSMAP_USE(_var)   \
> DYNDBG_CLASSMAP_USE_(_var, __UNIQUE_ID(ddebug_class_user))
> #define DYNDBG_CLASSMAP_USE_(_var, _uname)  \
> extern struct ddebug_class_map _var;\
> struct ddebug_class_user __used \
> __section("__dyndbg_class_users") _uname = {\
> .user_mod_name = KBUILD_MODNAME,\
> .map = &_var,   \
> }
>
> is there something subtle (or obvious) wrong with my macro ?


git log --grep __UNIQUE_ID

led me to a significant hint, in:

commit e9092d0d97961146655ce51f43850907d95f68c3
Author: Linus Torvalds 
Date:   Mon Apr 9 10:34:07 2018 -0700

Fix subtle macro variable shadowing in min_not_zero()


[ That said, __UNIQUE_ID() itself has several issues that make it less
  than wonderful.

  In particular, the "uniqueness" has a fallback on the line number,
  which means that it's not actually unique in more complex cases if you
  don't build with gcc or clang (which have working unique counters that
  aren't tied to line numbers).

  That historical broken fallback also means that we have that pointless
  "prefix" argument that doesn't actually make much sense _except_ for
  the known-broken case. Oh well. ]

[jimc@frodo wk-suren]$ ack 'define __UNIQUE_ID'
include/linux/compiler-clang.h
11:#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix),
__COUNTER__)

include/linux/compiler-gcc.h
42:#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix),
__COUNTER__)

include/linux/compiler.h
182:# define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_,
prefix), __LINE__)

tools/testing/scatterlist/linux/mm.h
65:#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix),
__COUNTER__)

that 3rd defn, using __LINE__ is what Linus was talking about.


for a quick-&-dirty test, I moved the offending DYNDBG_CLASSMAP_USE()
decls down a few lines,

this made the linker errors go away.

It doesnt feel like a robust solution, but Im going with it.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [jimc:dd-fix-2g] BUILD REGRESSION 664531695395972a1684dbc3604731db280b479e

2023-06-13 Thread jim . cromie
Trouble with __UNIQUE_ID

Im getting an error which "shouldnt be possible", but is happening anyway.


On Mon, Jun 12, 2023 at 2:55 PM kernel test robot  wrote:
>
> tree/branch: https://github.com/jimc/linux.git dd-fix-2g
> branch HEAD: 664531695395972a1684dbc3604731db280b479e  drm-drivers: 
> DRM_CLASSMAP_USE in 2nd batch of drivers, helpers
>
> Error/Warning: (recently discovered and may have been fixed)
>
> hppa-linux-ld: 
> drivers/gpu/drm/nouveau/nouveau_drm.o:(__dyndbg_class_users+0x0): multiple 
> definition of `__UNIQUE_ID_ddebug_class_user323'; 
> drivers/gpu/drm/radeon/radeon_drv.o:(__dyndbg_class_users+0x0): first defined 
> here
> include/drm/drm_print.h:421:9: error: implicit declaration of function 
> '_dynamic_func_call_cls' [-Werror=implicit-function-declaration]
> riscv64-linux-ld: drivers/gpu/drm/gud/gud_drv.o:(__dyndbg_class_users+0x0): 
> multiple definition of `__UNIQUE_ID_ddebug_class_user305'; 
> drivers/gpu/drm/qxl/qxl_drv.o:(__dyndbg_class_users+0x0): first defined here
> riscv64-linux-ld: 
> drivers/gpu/drm/nouveau/nouveau_drm.o:(__dyndbg_class_users+0x0): multiple 
> definition of `__UNIQUE_ID_ddebug_class_user374'; 
> drivers/gpu/drm/radeon/radeon_drv.o:(__dyndbg_class_users+0x0): first defined 
> here
>
> Error/Warning ids grouped by kconfigs:
>
> gcc_recent_errors
> |-- parisc-allyesconfig
> |   `-- 
> multiple-definition-of-__UNIQUE_ID_ddebug_class_user323-drivers-gpu-drm-radeon-radeon_drv.o:(__dyndbg_class_users):first-defined-here
> |-- riscv-allyesconfig
> |   |-- 
> multiple-definition-of-__UNIQUE_ID_ddebug_class_user305-drivers-gpu-drm-qxl-qxl_drv.o:(__dyndbg_class_users):first-defined-here
> |   `-- 
> multiple-definition-of-__UNIQUE_ID_ddebug_class_user374-drivers-gpu-drm-radeon-radeon_drv.o:(__dyndbg_class_users):first-defined-here
> `-- x86_64-randconfig-a015-20230612
> `-- 
> include-drm-drm_print.h:error:implicit-declaration-of-function-_dynamic_func_call_cls
>
> elapsed time: 756m
>
> configs tested: 101
> configs skipped: 6
>
> tested configs:
> alphaallyesconfig   gcc
> alpha   defconfig   gcc
> alpharandconfig-r022-20230612   gcc
> arc  allyesconfig   gcc
> arc defconfig   gcc
> arc  randconfig-r015-20230612   gcc
> arc  randconfig-r043-20230612   gcc
> arm  allmodconfig   gcc
> arm  allyesconfig   gcc
> arm defconfig   gcc
> arm  randconfig-r046-20230612   clang
> arm64allyesconfig   gcc
> arm64   defconfig   gcc
> cskydefconfig   gcc
> hexagon  randconfig-r041-20230612   clang
> hexagon  randconfig-r045-20230612   clang
> i386 allyesconfig   gcc
> i386 buildonly-randconfig-r006-20230612   clang
> i386  debian-10.3   gcc
> i386defconfig   gcc
> i386 randconfig-i001-20230612   clang
> i386 randconfig-i002-20230612   clang
> i386 randconfig-i003-20230612   clang
> i386 randconfig-i004-20230612   clang
> i386 randconfig-i005-20230612   clang
> i386 randconfig-i006-20230612   clang
> i386 randconfig-i011-20230612   gcc
> i386 randconfig-i012-20230612   gcc
> i386 randconfig-i013-20230612   gcc
> i386 randconfig-i014-20230612   gcc
> i386 randconfig-i015-20230612   gcc
> i386 randconfig-i016-20230612   gcc
> i386 randconfig-r012-20230612   gcc
> i386 randconfig-r014-20230612   gcc
> i386 randconfig-r035-20230612   clang
> loongarchallmodconfig   gcc
> loongarch allnoconfig   gcc
> loongarchbuildonly-randconfig-r001-20230612   gcc
> loongarch   defconfig   gcc
> m68k allmodconfig   gcc
> m68k allyesconfig   gcc
> m68k buildonly-randconfig-r004-20230612   gcc
> m68kdefconfig   gcc
> mips allmodconfig   gcc
> mips allyesconfig   gcc
> mips randconfig-r001-20230612   gcc
> mips randconfig-r011-20230612   clang
> mips randconfig-r021-20230612   clang
> nios2   defconfig   gcc
> nios2randconfig-r032-20230612   gcc
> openrisc randconfig-r013-20230612   gcc
> openrisc randconfig-r024-20230612   gcc
> parisc   allyesconfig   gcc
> parisc  defconfig   gcc
> parisc   

Re: trouble running lkp-tests

2023-05-31 Thread jim . cromie
On Sat, May 20, 2023 at 11:02 PM Valdis Klētnieks
 wrote:
>
> On Fri, 19 May 2023 13:38:37 -0600, jim.cro...@gmail.com said:
> > hi all,
> >
> > anyone familiar enough with running lkp-tests to recognize these errors ?
>
> > any hints / guesses welcome !
>
> Did you already check all the embarrassingly obvious things like a file system
> being full and/or out of inodes, dangling symlinks that point to somewhere
> in the middle of the Indian Ocean, or a file system mounted R/O?

well, theres this in the readme, from 2022.
# Note: lkp doesn't support ruby >= 3.0, default ruby version should be 2.x

support is now improved/ing (fedora ships 3.2)
and ruby 3.2 has been added to their test targets.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


trouble running lkp-tests

2023-05-19 Thread jim . cromie
hi all,

anyone familiar enough with running lkp-tests to recognize these errors ?

1st, from inside a virtme VM -

bash-5.2# /usr/local/bin/lkp split-job --compatible
/home/jimc/projects/lkp-tests.git/jobs/kmemleak-test.yaml
/home/jimc/projects/lkp-tests.git/jobs/kmemleak-test.yaml =>
./kmemleak-test-defaults.yaml
bash-5.2# /usr/local/bin/lkp run ./kmemleak-test-defaults.yaml
2023-05-19 13:04:31 -0600 WARN -- Jobfile is a dirty file, better to
run 'lkp split-job --compatible ./kmemleak-test-defaults.yaml' first
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `grep -w '^memory:'
/home/jimc/projects/lkp-tests.git/hosts/(none)'
/home/jimc/projects/lkp-tests.git/bin/run-local:121:in `':
undefined method `chomp' for nil:NilClass (NoMethodError)

job['memory'] ||= `grep -w '^memory:'
#{LKP_SRC}/hosts/#{HOSTNAME}`.split(' ')[1].chomp

  ^^
bash-5.2# /usr/local/bin/lkp split-job --compatible
./kmemleak-test-defaults.yaml
/tmp/20230519-534-276vfc => ./20230519-534-276vfc-defaults.yaml
bash-5.2# /usr/local/bin/lkp run ./20230519-534-276vfc-defaults.yaml
2023-05-19 13:05:41 -0600 WARN -- Jobfile is a dirty file, better to
run 'lkp split-job --compatible ./20230519-534-276vfc-defaults.yaml'
first
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `grep -w '^memory:'
/home/jimc/projects/lkp-tests.git/hosts/(none)'
/home/jimc/projects/lkp-tests.git/bin/run-local:121:in `':
undefined method `chomp' for nil:NilClass (NoMethodError)

job['memory'] ||= `grep -w '^memory:'
#{LKP_SRC}/hosts/#{HOSTNAME}`.split(' ')[1].chomp

  ^^

somehow, ruby is broken / unavailable inside the VM.

2 - on the host itself

[jimc@frodo lkp-tests.git]$ sudo lkp run ./20230519-819840-khtr75-defaults.yaml
[sudo] password for jimc:
2023-05-19 13:08:54 -0600 WARN -- Jobfile is a dirty file, better to
run 'lkp split-job --compatible
./20230519-819840-khtr75-defaults.yaml' first
current kernel cannot support kmemleak, please check CONFIG_DEBUG_KMEMLEAK
  /home/jimc/projects/lkp-tests.git/lib/debug.sh:12: die
  /home/jimc/projects/lkp-tests.git/tests/kmemleak-test:8: main
  :0:
kill 825577 vmstat --timestamp -n 10
kill 825575 dmesg --follow --decode
wait for background processes: 825579 meminfo
grep: warning: stray \ before :
grep: warning: stray \ before :
2023-05-19 13:08:58 WARN -- job exited due to die
/lkp/result/kmemleak-test/defaults/frodo/fedora/defconfig/gcc/6.2.15-300.fc38.x86_64/3
grep: warning: stray \ before :
2023-05-19 13:08:58 WARN -- job exited due to die
/lkp/result/kmemleak-test/defaults/frodo/fedora/defconfig/gcc/6.2.15-300.fc38.x86_64/3
grep: warning: stray \ before :
2023-05-19 13:08:58 WARN -- job exited due to die
/lkp/result/kmemleak-test/defaults/frodo/fedora/defconfig/gcc/6.2.15-300.fc38.x86_64/3
grep: warning: stray \ before :
2023-05-19 13:08:58 WARN -- job exited due to die
/lkp/result/kmemleak-test/defaults/frodo/fedora/defconfig/gcc/6.2.15-300.fc38.x86_64/3
grep: warning: stray \ before :
2023-05-19 13:08:58 WARN -- job exited due to die
/lkp/result/kmemleak-test/defaults/frodo/fedora/defconfig/gcc/6.2.15-300.fc38.x86_64/3
grep: warning: stray \ before :
2023-05-19 13:08:58 WARN -- job exited due to die
/lkp/result/kmemleak-test/defaults/frodo/fedora/defconfig/gcc/6.2.15-300.fc38.x86_64/3
grep: warning: stray \ before :
grep: warning: stray \ before :
2023-05-19 13:08:58 WARN -- job exited due to die
/lkp/result/kmemleak-test/defaults/frodo/fedora/defconfig/gcc/6.2.15-300.fc38.x86_64/3
/home/jimc/projects/lkp-tests.git/lib/data_store.rb:62:in
`initialize': wrong number of arguments (given 2, expected 1)
(ArgumentError)
from /home/jimc/projects/lkp-tests.git/lib/common.rb:24:in `new'
from /home/jimc/projects/lkp-tests.git/lib/common.rb:24:in `block in
add_cached_method'
from /home/jimc/projects/lkp-tests.git/lib/data_store.rb:246:in `create_new'
from /home/jimc/projects/lkp-tests.git/lib/nresult_root.rb:241:in
`create_layout'
from /home/jimc/projects/lkp-tests.git/lib/nresult_root.rb:337:in
`create_tables_layout'
from /home/jimc/projects/lkp-tests.git/bin/run-local:167:in `'


any hints / guesses welcome !

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Organizing patches/build artifacts against multiple trees

2023-04-26 Thread jim . cromie
On Sun, Feb 19, 2023 at 8:21 PM Sarah Langstrom
 wrote:
>
> For developers that find themselves with multiple in progress
> patchsets against multiple trees, how do you organize them locally? I
> add each tree as a remote and use git-worktree for multiple streams of
> development.

I use worktrees as well. they all use the same repo, so its gotta save space.
I tend to reuse them too, and rarely need make clean between swaps.

[jimc@frodo f2]$ git worktree list
/home/jimc/projects/lx/linux.git  457391b03803 [master]
/home/jimc/projects/lx/wk-next75eada68d460 [kmemleak-format-tweaks]
/home/jimc/projects/lx/wk-ref 89b88285f7ba [diet-x1b]
/home/jimc/projects/lx/wk-rpi b762dfa091f8 [maph]
/home/jimc/projects/lx/wk-suren   8660484ed1cf [modules-next]
/home/jimc/projects/lx/wk-testb61bb42d2cdc [dd-fix-1d]

FWIW, I have ./builds/* folders, each with a .config file and a 2 line makefile:

# Automatically generated by /home/jimc/projects/lx/wk-rpi/Makefile: don't edit
include /home/jimc/projects/lx/wk-rpi/Makefile

> I wish I had a little working area to go along with each
> tree/tracking branch where I could store patches and configs related
> to that tree without committing them, but still be able to back them
> up when I push the trees to my backup NAS. I am starting to lose track
> of which patchsets worked against which tree and which commit by
> sticking them all in one ~/patches dir.

have you seen git stash ?
it will do at least some of what you want.

>
> Another issue I have is that I put files to build a small initramfs
> inside of linux/usr and a Makefile of my own to build the initramfs
> and start up qemu. Again, I want to use git to store it with my
> branches on my NAS, but I don't want to check it in. Does anyone else
> have tips for dealing with adding personal scaffolding like this
> without having it get accidentally lost? Right now they are just
> untracked files that I sometimes delete by mistake.
>

I use virtme to do my testing.
It exposes your host machine inside a qemu vm,
so the env & tools in the vm are the same binaries that youre used to using.
Ive had to do ZERO messing with the qemu details
Id never even used qemu until virtme,
and other than some fiddling with its many --options
(some are pass thru to qemu)
it just works.

specifically, it does guest-tools setup, maybe its simple to reuse that..

virtme.guesttools 975097856 485798144 486818176  50% /run/virtme/guesttools
virtme.initmount0 975097856 485798144 486818176  50% /root

As to personal scaffolding, test scripts etc,
I keep them in the parent directory of all the worktrees,
and the vm's get it as the HOME dir via --cwd=../../..

[jimc@frodo f2]$ krun
vm --show-command --show-boot-console --kdir . --mods=auto --kopt
nokaslr --rwdir=/root=/home/jimc/projects/lx/boots-dump/v6.3-7-gb762dfa091f8
--cwd=../../.. --kopt dynamic_debug.verbose=3 --qemu-opts -m 2G --smp
3

then I can just source the shell tools I want

[   21.770154] virtme-init: udev is done
virtme-init: console is ttyS0
bash-5.2# . test-funcs.rc
:#>


> Thanks,
> Sarah
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kernel developer proccess

2023-04-24 Thread jim . cromie
On Tue, Mar 21, 2023 at 5:21 PM Panagiotis Filippakopoulos
 wrote:
>
> Hello. I would like to ask, what your advise would be to a person that wants 
> to get in the kernel development industry, without having a coputer science 
> degree. I attended some classes for computer science, but due to some 
> difficulties i left after the first semester. During that time we learned a 
> little bit about operating systems and the basics of programming. Is learning 
> operating systems C and Assembly, for a specific architecture, (e.g. x86) a 
> good start? What should my steps be after that? Thank you in advance.
>
> Filippakopoulos Panagiotis


You should start smaller.
C is hard.  kernel programming is harder.
You should definitely learn several other languages 1st
Python for example.

But really, if you havent already,
you should start by getting a Linux distro running on a cheap laptop.
Then you can scratch any itch.
and youll have the tools, like a compiler to complain about your syntax errors


> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: 2 modules from 1 source ?

2022-12-20 Thread jim . cromie
On Mon, Dec 19, 2022 at 11:36 AM Greg KH  wrote:
>
> On Mon, Dec 19, 2022 at 10:02:42AM -0700, jim.cro...@gmail.com wrote:
> > On Mon, Dec 19, 2022 at 9:37 AM  wrote:
> > >
> > > Id like to build 2 modules (with different names)
> > > from a single source file, with 2nd being dependent
> > > on the 1st.
> > >
> > > Specifically, Ive got:
> > > lib/test_dynamic_debug.c
> > >
> > > I want
> > > A:  lib/test_dynamic_debug.ko
> > > B:  lib/test_dynamic_debug_submod.ko
> > >
> > > I expect that the code just needs an #ifdef #else #endif
> > > block to clearly put the dependor & dependee elements
> > > next to each other.
> > >
> > > My question is how to do this in the Makefile ?
> > > this does most of it
> > >
> > > --- a/lib/Makefile
> > > +++ b/lib/Makefile
> > > @@ -78,7 +78,8 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o
> > >  obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
> > >  obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
> > >  obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
> > > -obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
> > > +obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
> > > test_dynamic_debug_submod.o
> > > +CFLAGS_test_dynamic_debug_submod.o += -DTEST_DYNAMIC_DEBUG_SUBMOD
> > >  obj-$(CONFIG_TEST_PRINTF) += test_printf.o
> > >
> > > but how do I tell it the 2nd target ?
> >
> > more to the point, this doesnt work (nor do permutations), I miss something:
> >
> > +($obj)/test_dynamic_debug_submod.o: ($obj)/test_dynamic_debug.c
>
> Pleaase don't do that :(
>
> If you _REALLY_ need to do this, then just #include your .c file into
> two other .c files.  And keep everything in your #included .c file
> static to make sure you don't have duplicate global symbols.
>

that approach works perfectly, thanks.
and no CFLAGs or weird rules in the Makefile.
dependent module is 2 lines - define, include.

> Otherwise it is impossible for the same .o to be linked into two
> different modules (or into the kernel image itself) as there will be
> duplicate global symbols (as that .c file had to have something global
> for you to be able to call into it.)
>
> But step back, what is the problem that you really want to solve here
> that you feel somehow a single .c file built twice would be correct?
> Especially with code in lib/ that should not be needed at all as you are
> building "library" functions that only get included if they are actually
> used in the large kernel image.
>

Heres my story:

CONFIG_DRM_USE_DYNAMIC_DEBUG=y has a regression;
i915.ko depends upon drm.ko, which is loaded 1st.
drm.debug= is set as last step in the modprobe drm,
ie before modprobe i915 is run.
So i915's drm_dbg callsites arent enabled at module_init, or later.
Once drm.debug is updated again (post modprobe), dyndbg's
param-callback applies the drm.debug bits to enable the DRM_UT_* classes,
this time seeing i915 and drm-* helpers too.

The fix Im working on splits DECLARE_DYNDBG_CLASSMAP
into DYNDBG_CLASSMAP_DEFINE & DYNDBG_CLASSMAP_USE.
This comports better with K define-once, refer-many model,
and distinguishes _USErs (i915, helpers) from DEFINEr (drm).
So classmap users get cataloged separately, and get extra behavior,
to lookup the state var of the definer of the param,
and apply it to the module being loaded.

I need to recapitulate this dependent module scenario.
In test_dynamic_debug, Ive reworked the DECLARE_*s
to ifdef'd  _DEFINE and _USE blocks.
this makes the parent/child distinction very clear.

Using the same code 2x means that logging is same baseline for both.

It should mean that ALL the enablements
are duplicated, which should be easy to verify.



> thanks,
>
> greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: 2 modules from 1 source ?

2022-12-19 Thread jim . cromie
On Mon, Dec 19, 2022 at 9:37 AM  wrote:
>
> Id like to build 2 modules (with different names)
> from a single source file, with 2nd being dependent
> on the 1st.
>
> Specifically, Ive got:
> lib/test_dynamic_debug.c
>
> I want
> A:  lib/test_dynamic_debug.ko
> B:  lib/test_dynamic_debug_submod.ko
>
> I expect that the code just needs an #ifdef #else #endif
> block to clearly put the dependor & dependee elements
> next to each other.
>
> My question is how to do this in the Makefile ?
> this does most of it
>
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -78,7 +78,8 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o
>  obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
>  obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
>  obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
> -obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
> +obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
> test_dynamic_debug_submod.o
> +CFLAGS_test_dynamic_debug_submod.o += -DTEST_DYNAMIC_DEBUG_SUBMOD
>  obj-$(CONFIG_TEST_PRINTF) += test_printf.o
>
> but how do I tell it the 2nd target ?

more to the point, this doesnt work (nor do permutations), I miss something:

+($obj)/test_dynamic_debug_submod.o: ($obj)/test_dynamic_debug.c

> make[2]: *** No rule to make target 'lib/test_dynamic_debug_submod.o',
> needed by 'lib/modules.order'.  Stop.
> make[1]: *** [/home/jimc/projects/lx/wk-test/scripts/Makefile.build:500:
> lib] Error 2
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


2 modules from 1 source ?

2022-12-19 Thread jim . cromie
Id like to build 2 modules (with different names)
from a single source file, with 2nd being dependent
on the 1st.

Specifically, Ive got:
lib/test_dynamic_debug.c

I want
A:  lib/test_dynamic_debug.ko
B:  lib/test_dynamic_debug_submod.ko

I expect that the code just needs an #ifdef #else #endif
block to clearly put the dependor & dependee elements
next to each other.

My question is how to do this in the Makefile ?
this does most of it

--- a/lib/Makefile
+++ b/lib/Makefile
@@ -78,7 +78,8 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o
 obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
-obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
+obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
test_dynamic_debug_submod.o
+CFLAGS_test_dynamic_debug_submod.o += -DTEST_DYNAMIC_DEBUG_SUBMOD
 obj-$(CONFIG_TEST_PRINTF) += test_printf.o

but how do I tell it the 2nd target ?

make[2]: *** No rule to make target 'lib/test_dynamic_debug_submod.o',
needed by 'lib/modules.order'.  Stop.
make[1]: *** [/home/jimc/projects/lx/wk-test/scripts/Makefile.build:500:
lib] Error 2




CFLAGS_test_dynamic_debug_submod.o += -\ DTEST_DYNAMIC_DEBUG_SUBMOD
A.ko:

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: unmap memory mapped with devm_ioremap_resource

2022-12-09 Thread jim . cromie
On Fri, Dec 9, 2022 at 9:14 AM Adrian Fiergolski
 wrote:
>
> Hi,
>
> Does the community have any other ideas? Or I am wrong, and devm_iounmap is 
> enough?
>

I dunno, but it says you asked ~4 hrs ago.
I bet you could just try it and get an answer faster.
Do feel free to report back.

> Regards,
> Adrian
>
> On 6.12.2022 22:23, Adrian Fiergolski wrote:
>
> Hi Costa,
>
> Thank you for your reply.
>
> I saw 'devm_iounmap' , but, correct me if I am wrong, I think is not enough.
>
> devm_ioremap_resource calls __devm_ioremap_resource (link) which calls 
> eventually __devm_request_region (link) and __devm_ioremap (link). Those two 
> will allocate 2 devres: devm_region_release and devm_ioremap_release.
>
> The proposed devm_iounmap (link) seems to destroy only devm_ioremap_release 
> devres.
>
> Regards,
> Adrian
>
> On 2.12.2022 19:01, Constantine Shulyupin wrote:
>
> Hi,
>
> I suppose you are looking for `devm_iounmap`.
> You can find example of usage in `drivers/fpga/dfl.c`:
>
> ...
> feature->ioaddr =
>devm_ioremap_resource(binfo->dev,
>  >mmio_res);
> ...
>
> static void build_info_complete(struct build_feature_devs_info *binfo)
> {
>devm_iounmap(binfo->dev, binfo->ioaddr);
>devm_release_mem_region(binfo->dev, binfo->start, binfo->len);
> }
>
> Regards,
> Costa
>
>
> On Fri, 2 Dec 2022 at 19:25, Adrian Fiergolski
>  wrote:
>
> Hello,
>
> I am extending xilinx-hls driver
> (https://github.com/Xilinx/linux-xlnx/blob/master/drivers/media/platform/xilinx/xilinx-hls.c)
> to support of_overlay.
>
> In order to reflect in the driver changes being applied by the overlay
> to the device tree, I need to unmap first the memory mapped with
> devm_ioremap_resource. How to do it properly?
>
> I think it's uncommon, as normally kernel (devm_* functions) manages
> those resources itself with devres, so I can't find inspiration in other
> drivers.
>
> Regards,
> Adrian
>
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


gdb vmlinux scripting

2022-11-28 Thread jim . cromie
so Im debugging a kernel,
running inside virtme  (I cant recommend it enough)

using 2 terminals, each in build-dir

1st runs
function dkrunk () {
echo vm$KRUN_SHOW $KRUN_STDS $KDBG_OPTS $* $QM_OPTS --smp 3 -s -S
virtme-run $KRUN_SHOW $KRUN_STDS $KDBG_OPTS $* $QM_OPTS --smp 3 -s -S
# -qmp tcp:localhost:,server,nowait
}

2nd runs:
alias tui='gdb --tui -q -x ../../../gdb-2 vmlinux'

that script is

# seems I need a hardware breakpoint to get started,
# is that the case for anyone else ?
hbreak dynamic_debug_init
c
b strcmp if cs == ct
c


If you do this, youll find all the places where
strcmp is called on identical args.

Most of them I dont want to see,
but what kind of syntax lets me look up the frame(s)
to select only the contexts of interest ?

it would be useful enough to test just the caller file,
that would get me a long way

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: question about boot_params global variables

2022-11-20 Thread jim . cromie
On Mon, Nov 14, 2022 at 11:41 AM Saad Masood  wrote:
>
> Hi Jim,
> In C, two global variables with the same name are converted to one global 
> variable (same memory address space).   So, the same variable is referenced 
> with or without the 'extern' keyword.
>
> Thanks,
>
>

thanks Saad,

its nice when a thread reaches a tight conclusion.


>
> Saad
>
> On Mon, Nov 14, 2022 at 11:23 AM  wrote:
>>
>> On Tue, Aug 16, 2022 at 4:10 AM shiyu chou  wrote:
>> >
>> > Hello all:
>> > In arch x86 directory I found two global variables with the same 
>> > name(master branch):
>> > 1.arch/x86/boot/main.c
>> > near line 18: struct boot_params boot_params __attribute__((aligned(16)));
>> > 2.arch/x86/kernel/setup.c
>> > near line 75: struct boot_params boot_params;
>> > Is that wrong to define two global variables with the same name? And when 
>> > use extern to reference the variable,which one did it reference?
>> >
>>
>> hi, did you figure out a satisfactory answer ?
>>
>> what happens when you build with W=1 ?
>>
>>
>> > ___
>> > Kernelnewbies mailing list
>> > Kernelnewbies@kernelnewbies.org
>> > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: question about boot_params global variables

2022-11-14 Thread jim . cromie
On Tue, Aug 16, 2022 at 4:10 AM shiyu chou  wrote:
>
> Hello all:
> In arch x86 directory I found two global variables with the same name(master 
> branch):
> 1.arch/x86/boot/main.c
> near line 18: struct boot_params boot_params __attribute__((aligned(16)));
> 2.arch/x86/kernel/setup.c
> near line 75: struct boot_params boot_params;
> Is that wrong to define two global variables with the same name? And when use 
> extern to reference the variable,which one did it reference?
>

hi, did you figure out a satisfactory answer ?

what happens when you build with W=1 ?


> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel compile message

2022-11-02 Thread jim . cromie
On Mon, Oct 31, 2022 at 8:07 AM Anatoly Pugachev  wrote:
>
> got it again...
>
> mator@ttip:~/linux-2.6$ make V=1 -j olddefconfig; nice make -j20 &&
> nice make -j20 modules

just make might throw less stuff to the screen.

> make[1]: /bin/sh: Bad address

I pasted that line to google.
1st chunk of results are from stackexchange / serverfault

they look promising
/

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: work one webcam out of two webcam connect to xhci controller for 2 usb3.0 ports

2022-10-18 Thread jim . cromie
Let's keep this on the list.
I'm sure I don't have Silver Bullet answers.



On Tue, Oct 18, 2022, 11:15 AM Malatesh  wrote:

> Hi.
> Thank you for the interest you have shown.
>
>
> - both cameras work one at a time ?
> [A]: No. I am using one by one and not at one time both cameras
> - does order of plugin affect which one blanks ?
> [A]: First plugged camera will give blank and second plugged will work
>

This certainly suggests two cameras are on or plugged in at the same time.
 that contradicts your first answer

- are they both the same camera model ?
> [A]: No one is logitech and another is microsoft
> - can you borrow a 3rd camera ?
> [A]: Third camera works
>

I think you need to retest and permute all combinations or at least some of
them.

I suspect your application doesn't know what to do with two cameras why
don't you try another app and see if it works. Cheese is the one on my
desktop


> Actual Error:
> When I click camera preview with two camera connected, one is giving error
> some time with "xhci_configure_reset_endpoint:4543 Error to set dequeue
> ptr for endpoint 3, 81, err 18, 0".
> This is because "ep status is 0 and *Endpoint is disabled".*
>
> Full Log:
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011861> set halted 1
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011890> real interrupt
> (status=0x0008)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011897> event[77] = 32
> (0x 0x0c00 0x02038000)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011901> trb 0x0 status c
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011904> slot=2 epno=3
> stream=0 remainder=0 status=12, td_event 0x0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011907> stream_id=0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011910>
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011940> trb halted 1, running
> 0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011943>
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011944> Ep(129) No:129
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011946> Ep ID(129to3):3
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011949> dev 2, ep address 81
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011952> xfer
> 0xfe003198f148, 0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011954> ep 81 is not started
> yet
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011957> --> epno:3, Oct
> 18 16:35:42 WT544810D076E1 kernel: <3645.011861> set halted 1
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011890> real interrupt
> (status=0x0008)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011897> event[77] = 32
> (0x 0x0c00 0x02038000)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011901> trb 0x0 status c
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011904> slot=2 epno=3
> stream=0 remainder=0 status=12, td_event 0x0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011907> stream_id=0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011910>
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011940> trb halted 1, running
> 0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011943>
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011944> Ep(129) No:129
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011946> Ep ID(129to3):3
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011949> dev 2, ep address 81
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011952> xfer
> 0xfe003198f148, 0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011954> ep 81 is not started
> yet
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011957> --> epno:3,
> *epstatus:0* device:2, ep_address 81
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011960> > *Endpoint is
> disabled*
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011962>
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011965> command[5] = 16
> (0x09891001, 0x, 0x02034000)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012003> real interrupt
> (status=0x0008)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012010> event[78] = 33
> (0x000100fffdd0 0x1300 0x02008400)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012013> Received command event
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012042> trb 1300, 2008400
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012046> src 16,
> (0x09891001, 0x, 0x02034000)
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012051> -> Set dequeue
> ptr for EP No:3, EP Addr:81, EP Status:0, EP Error:18
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012057> [ERROR] -
> xhci_configure_reset_endpoint:4543 Error to set dequeue ptr for endpoint
> 3, 81, err 18, 0
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012061> ---> kick_ep 1 called:
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.012064> endpoint is not
> running 3, 81, 18 device:2, ep_address 81
>
> Oct 18 16:35:42 WT544810D076E1 kernel: <3645.011960> >* Endpoint is
> disabled*
>
> Oct 18 16:35:42 

Re: Faster, incremental depmod when adding modules?

2022-10-13 Thread jim . cromie
On Sun, Aug 21, 2022 at 12:46 PM Ian Pilcher  wrote:
>
> When installing 1 or more out-of-tree modules within
> /lib/modules/$UNAME, is it possible to run depmod in an incremental
> fashion - adding symbols from the new modules to modules.dep[.bin]
> without re-scanning all of the other modules from that kernel version?
>
> I've tried specifying the new module files, but that seems to create a
> completely new modules.dep containing *only* the symbols from the new
> modules (which obviously isn't very useful).
>

OPTIONS
   -a, --all
   Probe all modules. This option is enabled by default if no
file names are given in the command-line.

   -A, --quick
   This option scans to see if any modules are newer than the
modules.dep file before any work is done: if not, it silently exits
rather than regenerating the files.

2nd looks like what u want

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: work one webcam out of two webcam connect to xhci controller for 2 usb3.0 ports

2022-10-13 Thread jim . cromie
On Wed, Oct 12, 2022 at 11:21 AM Malatesh  wrote:
>
> Hi Team,
>
> Good Morning/Afternoon/Evening.
>
> I connect two usb webcameras and one mouse, one keyboard to  xhci controller, 
> which has 4 usb v3.x ports.
> Here, keyboard and mouse works fine without any issue.
> But out of two cameras, only one camera works( I mean when I click preview 
> only one camera show and one camera show blank )
>

lemme ask some obvious questions:
- both cameras work one at a time ?
- does order of plugin affect which one blanks ?
- are they both the same camera model ?
- can you borrow a 3rd camera ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: mabe a bug in kernel 5.4 since patchlevel 159 - dma error because use ttynull?

2022-10-13 Thread jim . cromie
On Thu, Oct 13, 2022 at 4:48 AM Simon Lindhorst  wrote:
>
> Hello all,
>
>
> when I updated my Kernel from version 5.4.155 to 5.4.215 I get an strange 
> xhci error:
>
> xhci-hcd f10f.usb3: ERROR unknown event type 37
> xhci-hcd f10f.usb3: ERROR Transfer event TRB DMA ptr not part of current 
> TD ep_index 2 comp_code 13
>
> After a lot of this messages, my hardware makes a reboot without any more 
> outputs.
>
> The error only occures when i add console=null to my kernel bootargs. When I 
> add instead console=ttyS0,115200 no error occured.
>
> Now I go back in kernelversions. The error occured first in version 5.4.159. 
> Between patchlevel 158 and 159 there is a change:
>
> --- linux-5.4.158/kernel/printk/printk.c2021-11-06 13:59:45.0 
> +0100
> +++ linux-5.4.159/kernel/printk/printk.c2021-11-12 14:43:05.0 
> +0100
> @@ -2193,8 +2193,15 @@
>  char *s, *options, *brl_options = NULL;
>  int idx;
>
> -if (str[0] == 0)
> +/*
> + * console="" or console=null have been suggested as a way to
> + * disable console output. Use ttynull that has been created
> + * for exacly this purpose.
> + */
> +if (str[0] == 0 || strcmp(str, "null") == 0) {
> +__add_preferred_console("ttynull", 0, NULL, NULL);
>  return 1;
> +}
>
>  if (_braille_console_setup(, _options))
>  return 1;
>
> I checked my kernelconfig and found that I have no ttynull device configured 
> (CONFIG_NULL_TTY=n). Add CONFIG_NULL_TTY=y to my kernelconfig doesn't made a 
> change.
>
> When I undo the change above, everything works fine.
>
>
> Does anybody know, what could be the main trigger for the error above?
>

while there have been lots of change to printk,
the code you cite is still there.
If that code is a candidate for the root-cause,
and you can re-create the error on master,
you are 1/2 the way to getting it fixed.

Also, note latest:

commit 3ef4ea3d84ca568dcd57816b9521e82e3bd94f08
Merge: 30d024b5058e 5eb17c1f458c
Author: Linus Torvalds 
Date:   Wed Mar 23 10:54:27 2022 -0700

Merge tag 'printk-for-5.18' of
git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux

Pull printk updates from Petr Mladek:

 - Make %pK behave the same as %p for kptr_restrict == 0 also with
   no_hash_pointers parameter

 - Ignore the default console in the device tree also when console=null
   or console="" is used on the command line

 - Document console=null and console="" behavior


that last one is pertinent.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


howto strip trailing newline from a format string at compile-time ?

2022-10-12 Thread jim . cromie
hi all

So Im (always) hacking on dynamic-debug..

Ive added a 'T' flag, which causes dyndbg to send its message
to /sys/kernel/tracing/trace instead of syslog (p does that).

trouble is, pr_debug() calls almost always have a trailing newline,
and ftrace adds its own, so the tracefile has empty lines after each
pr_debug's message.


I would like to fix this in the format-string, with a macro,
and add the newline explicitly, when given originally, for the 'p'/syslog case.
While still needing an add-newline? decision,
it avoids scanning format or sprint-d bufs for the trailing newline.


ie
#define strip_trailing_newline(str) .
#define has_trailing_newline(str) ...

theyd get used in:
#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \
...
.format = strip_trailing_newline(fmt), \
.add_nl = has_trailing_newline(fmt), \

that new .add_nl bit-field might be difficult - the other flags in _ddebug
are not individual bit-fields, but I think this would have to be separate
to be initializable in the macro.  maybe no big deal.

and how to fix the 'fmt expanded 2x' problem ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Where do I put my new driver?

2022-09-21 Thread jim . cromie
On Mon, Aug 8, 2022 at 12:21 PM Alec Matthews  wrote:
>
> I've created a new device driver that is responsible for controlling a
> GPIO expander. This driver contains gpio_chip code, pinmux/pinconf,
> code, pwm, and irq handlers.
>
> I'm not certain what I should name this driver. `pinctrl-*`, `gpio-*`,
> or something else?
>

that suggests that you have several different drivers.
each under their own tree to get the same "place"
as the ones already there, that build cleanly,
use the subsystem support, and work.

> I'm also not sure where this driver belongs in the source tree. Should
> it exist in drivers/gpio, drivers/pinctrl, or drivers/pwm?
>
> I have developed this driver out of tree, now I am trying to move it in
> tree so I can begin the patch process. I appreciate any insight that
> this list may have on where it belongs.
>

the path of least resistance might be to just put it in staging.
Once its there and building, thats a milestone.
then when it "works" there, thats clearly another.
then maybe break it up into several ko's if feedback says.

>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


difference between DECLARE_* and DEFINE_* macro namespaces ?

2022-09-21 Thread jim . cromie
difference between DECLARE_* and DEFINE_* macro namespaces ?




heres some quantitative observations

1st , raw usage counts

[jimc@frodo wk-test]$ ack DECLARE_\\w+ | wc
  12541   30583 1030008
[jimc@frodo wk-test]$ ack \\bDECLARE_\\w+ | wc
  11293   25240  897730

[jimc@frodo wk-test]$ ack \\bDEFINE_\\w+ | wc
  14746   42085 1222994
[jimc@frodo wk-test]$ ack DEFINE_\\w+ | wc
  16714   48172 1386881

used quite a lot. worth seeing the patterns...


this one seems telling it counts indent=0 lines,
ie Header lines, file-scope vars, global declarations etc.

]$ ack ^DEFINE_\\w+ | wc
   7392   19578  661324


[jimc@frodo wk-test]$ ack 'static DECLARE_\w+'  | wc
9203025   80318

so about 1/12 of the DECLAREs have static outside them.









#defines determine how many PATTERN uses there are.
lets count them.

[jimc@frodo wk-test]$ ack '#define DECLARE_\w+' | wc
3141384   27393
[jimc@frodo wk-test]$ ack '#define DEFINE_\w+' | wc
6952734   9

so, 2.3x DEFINE_/DECLARE_ definitions,
and 1.15x uses of those defns

interesting, not suggestive of anything..




lets look at one case

include/linux/spinlock_types_raw.h
71:#define DEFINE_RAW_SPINLOCK(x)  raw_spinlock_t x =
__RAW_SPIN_LOCK_UNLOCKED(x)

its a variable declaration, expecting ';' in caller to close it.

[jimc@frodo wk-test]$ ack DEFINE_RAW_SPINLOCK | wc
140 293   10455
[jimc@frodo wk-test]$ ack 'static DEFINE_RAW_SPINLOCK' | wc
116 2588705
[jimc@frodo wk-test]$ ack '^static DEFINE_RAW_SPINLOCK' | wc
107 2318009

140 uses, most with static, most of those at file-scope













so, all that said, I havent gleaned any heuristics

does anyone want to offer a more qualitative review ?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: git magic or usage wisdom.

2022-08-05 Thread jim . cromie
On Thu, Aug 4, 2022 at 1:58 PM Ismael Luceno  wrote:
>
> On 04/Aug/2022 13:24, jim.cro...@gmail.com wrote:
> > so I have this patchset (sent to lkml recently ),
> > it adds a new struct:
> > struct _ddebug_info
> <...>
> > is there some git command magic to work this ?
> >
> > in a pre-git world, I might try
> > perl -pi -e 's/_ddebug_info/_ddebug_stateinfo/g' 00*.patch
> >
> > that "might" work, but could also create a myriad of conflicts
> > when the patchset is 'git am' d
> > and it might apply clean but still break on compile ?
> >
> > anyone care to opine on the probability of success ?
> >
> > If I try this, I'll report back.
> > ISTM more likely than my doing it manually.
>
> The approach is fine :).
>

thanks for the confirm, and I like the ^+ filter, and the \b's
it limits the modifications tightly.

> Whatever you do, you can't escape testing that the patches apply and
> compile...
>

indeed. its embarrassing when crap escapes the lab.

> What you may simplify is the editing by chaining the commands to
> replay changes into a new branch:
>
> git format-patch -k --stdout base..old-branch |
>   perl -pe '...' | git am -3 -k
>
> Further automation seems counterproductive.
>

that pipeline is helpful, I will play with it.


> As for the editing, I would use the following perl code:
>
> if (/^\+/) { s/\b_ddebug_info\b/_ddebug_stateinfo/g }
>
> That way you limit edits only to new content, and the struct name is
> properly bounded by the regex.
>
> I guess that's about as robust as you can make it without going out of
> your way.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


git magic or usage wisdom.

2022-08-04 Thread jim . cromie
so I have this patchset (sent to lkml recently ),
it adds a new struct:
struct _ddebug_info

dyndbg: create and use struct _ddebug_info

this new struct gathers the linker provided vectors/sections:

 descs - the vector of descriptors in __dyndbg section.
 num_descs - length of the data/section



If I had an endless supply of free do-overs,
Id change the name to something a little less user-facing,
since its meant to ref the whole dyndbg-config-state

is there some git command magic to work this ?

in a pre-git world, I might try
perl -pi -e 's/_ddebug_info/_ddebug_stateinfo/g' 00*.patch

that "might" work, but could also create a myriad of conflicts
when the patchset is 'git am' d
and it might apply clean but still break on compile ?

anyone care to opine on the probability of success ?

If I try this, I'll report back.
ISTM more likely than my doing it manually.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Is arch/x86/boot/main.c main obsolete?

2022-07-18 Thread jim . cromie
On Sat, Jun 25, 2022 at 5:35 PM ebashinskii  wrote:

> CPU: Intel x86 KabyLake. I'm using 5.17 Kernel built from upstream and
> GRUB 2.04
>
> When debugging the kernel initialization process I found out that there is
> a function *void main(void)* in the source file *arch/x86/boot/main.c* (source
> link:
> https://elixir.bootlin.com/linux/v5.17/source/arch/x86/boot/main.c#L134) which
> seems to be the entry point which the boot loader is supposed to jump into.
>
> But *objdump*-ing the Kernel image shows that there is no such symbol as
> *main*. GDB attached to QEMU does not know about this symbol either.
>
> The earliest stage of Kernel Initialization I could manage to catch with
> GDB is *x86_64_start_kernel* (source link:
> https://elixir.bootlin.com/linux/v5.17/source/arch/x86/kernel/head64.c#L467
> )
>
>

What are you trying to do that start-kernel is insufficiently early ?

main.c 's that you dont hit dont really matter do they ?

fwiw, I really like virtme

virtme-run $KRUN_SHOW $KRUN_STDS $KDBG_OPTS $* $QM_OPTS --smp 3 -s -S

the -s -S stops me early enough to anything Ive needed to so far.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[PATCH] dogs -

2022-03-16 Thread Jim Cromie
In an attempt to solve frictions in:
https://lore.kernel.org/lkml/20220311044756.425777-3-jim.cro...@gmail.com/

And inspired by https://lwn.net/Articles/383362/

defines DOGS macro - an initialization expression, ie list of breeds,
each contained by C, an inner macro, undefd when DOGS is defined.

C gets 2 defs for 2 tasks:
(each with preceding undef to reinforce the pattern)
- initialize enum dog_enums = DOGS: C(a) DRM_UT_##a (must form a real token)
- stringify each dog in DOGS: C(a) #a

Then tries to repeat this macro-pattern in DEFINE_DYNAMIC_DEBUG_CLASSBITS.
DOGS --> DRM_DEBUG_CATS
C -> C  reused for clarity

Its close, but not quite right:
- want to pass in init-construct once
- expand it 2x, with 2 different defs for C()
- cant nest #defines, cant redef for 2nd expansion.

Is there a way to do this ?

theres also some aspirational stuff in there, maybe it communicates /
explains things better than this commit msg.

Signed-off-by: Jim Cromie 
---
 play/c-code/dogs.c | 149 +
 1 file changed, 149 insertions(+)
 create mode 100644 play/c-code/dogs.c

diff --git a/play/c-code/dogs.c b/play/c-code/dogs.c
new file mode 100644
index 000..7094982
--- /dev/null
+++ b/play/c-code/dogs.c
@@ -0,0 +1,149 @@
+
+// see https://lwn.net/Articles/383362/
+
+#define DOGS { C(JACK_RUSSELL), C(BULL_TERRIER), C(ITALIAN_GREYHOUND) }
+
+#undef C
+#define C(a) ENUM_##a
+enum dog_enums DOGS;
+
+#undef C
+#define C(a) #a
+
+char *dog_strings[] = DOGS;
+char *dog_to_string(enum dog_enums dog)
+{
+  return dog_strings[dog];
+}
+
+
+// self-documenting help composition
+#define DOCS { \
+  _doc_( CORE, "extra core info"), \
+  _doc_( DRIVER, "extra driver info"), \
+  _doc_( KMS, "extra kms"),\
+}
+
+// 2 decomposers
+#define _sym_(_sym, _help) DRM_synth_##_sym
+#define _help_(_sym, _help)"enables " #_sym " messages - " _help
+
+// use sym to enumerate the symbols into the enum
+#undef _doc_
+#define _doc_ _sym_
+enum cat_enums DOCS;
+
+// use -help- to initialize the doc-strings
+#undef _doc_
+#define _doc_ _help_
+char *doc_helps[] = DOCS;
+char *doc_to_string(enum cat_enums cat)
+{
+  return doc_helps[cat];
+}
+
+#define FLAGS_LEN 8
+struct dyndbg_classbits_param {
+   unsigned long *bits;/* ref to shared state */
+   const char flags[FLAGS_LEN];/* toggle these flags on bit-changes */
+   const int classes[];/* indexed by bitpos */
+};
+
+#define _DPRINTK_SITE_UNCLASSED 15
+
+#include 
+#include 
+
+#define OP(s, state, x) BOOST_PP_CAT(state, x)
+#define SEQ (b)(o)(o)(s)(t)
+
+enum foo {
+  BOOST_PP_SEQ_FOLD_LEFT(OP, BOOST_PP_SEQ_HEAD(SEQ), BOOST_PP_SEQ_TAIL(SEQ))
+};
+
+// local copy
+enum drm_debug_category {
+  DRM_UT_CORE,
+  DRM_UT_DRIVER,
+  DRM_UT_KMS,
+  DRM_UT_PRIME,
+  DRM_UT_ATOMIC,
+  DRM_UT_VBL,
+  DRM_UT_STATE,
+  DRM_UT_LEASE,
+  DRM_UT_DP,
+  DRM_UT_DRMRES,
+  DRM_UT_DEFAULT
+};
+
+#define DRM_UT_DEFAULT 15
+#define DRM_DEBUG_CATS {   \
+C(_CORE),  \
+C(_DRIVER),
\
+C(_KMS),   \
+C(_PRIME), \
+C(_ATOMIC),
\
+C(_VBL),   \
+C(_STATE), \
+C(_LEASE), \
+C(_DP),\
+C(_DRMRES),
\
+  C(_DEFAULT)  \
+  }
+
+#undef C
+#define C(_cat) DRM_UT_##_cat  // wo _ after UT get 2x decl on local copy
+enum drm_dogs DRM_DEBUG_CATS;
+
+
+/**
+ * DEFINE_DYNAMIC_DEBUG_CLASSBITS() - bitmap control of classed pr_debugs
+ * @sysname: sysfs-node name
+ * @_var:C-identifier of ulong holding bit-vector (Bits 0-14 are usable)
+ * @_flgs:   string with dyndbg flags: 'p' and/or 'T', and maybe "fmlt" also.
+ * @desc:string summarizing the controls provided
+ * @classes: vector of callsite.class_id's (uint:4, 15 is reserved)
+ *
+ * This macro implements a DRM.debug API style bitmap, mapping bits
+ * 0-14 to classes of prdbg's, as initialized in their .class_id fields.
+ * @_flgs chooses the debug recipient; p - syslog, T - tracefs, and
+ * can include log decorations; m - module, f - function, l - line_num
+ */
+
+#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, _var, _flgs, desc, ...) \
+   static struct dyndbg_classbits_param ddcats_##_var = {  \
+   .bits = &(_var),  

Re: *** Compiler is too old

2022-03-07 Thread jim . cromie
On Mon, Mar 7, 2022 at 3:30 AM Rogério Valentim Feitoza da Silva
 wrote:
>
> On Monday, 7 March 2022,  wrote:
>>
>> I was just perusing this
>> https://www.kernel.org/doc/html/latest/process/changes.html
>> it speaks to minimum versions of everything
>>
>> Its good to next thru a bit, youll find things you didnt know.
>> I dont need a PGP, but I know where to look for info now.
>>
>
> What distribution are you using, and what version?
>
> -Rogério Valentim


Im on Fedora-35.
so I use dnf install when 
are found missing by make process.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: *** Compiler is too old

2022-03-06 Thread jim . cromie
On Tue, Feb 22, 2022 at 7:19 PM Aruna Hewapathirane
 wrote:
>
> On Tue, Feb 22, 2022 at 8:48 PM Valdis Klētnieks
>  wrote:
> >
> > On Sun, 20 Feb 2022 23:52:47 -0500, Aruna Hewapathirane said:
> >
> > > *** Compiler is too old.
> > >
> > > What would be the sanest way to do this? Meaning upgrade gcc and friends ?
> >
> > Well... the answer to the posed question is, of course, "install gcc 5.1 or 
> > later"
>
>
> I tried to do that  believe me I jumped through lots of hoops but uh
> uh no cigar.. :(
>
> > (and even *that* is pretty damned ancient - some of us are chasing problems
> > with building the kernel with gcc 12.  gcc 5.1 was released on 4-22-2015).
>
>
> Show off, I had no idea there was a gcc 12  ( it is so good to hear
> from you after many moons Valdis
> how is the Jag and my warmest regards to miss drove a jag did not crash ? :)
> >

OK.  Im picturing Valdis' beard in a top-down E-type

I was just perusing this
https://www.kernel.org/doc/html/latest/process/changes.html
it speaks to minimum versions of everything

Its good to next thru a bit, youll find things you didnt know.
I dont need a PGP, but I know where to look for info now.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


macro arg reuse warnings, howto fix ?

2022-02-28 Thread jim . cromie
so, in this patchset :
https://patchwork.freedesktop.org/series/100289/

I get a macro warning I cannot solve with the usual local/auto
variable declaration
(the 2nd line in this macro)

#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(_fsname, _var, _flgs, desc, ...) \
__typeof__ (_fsname) fsname = _fsname; \
   MODULE_PARM_DESC(fsname, desc); \
   static struct dyndbg_classbits_param ddcats_##_var = { \
.bits = &(_var), \
.flags = _flgs, \
.classes = { __VA_ARGS__, _DPRINTK_SITE_UNCLASSED } \
   }; \
   module_param_cb(fsname, _ops_dyndbg_classbits, \
  _##_var, 0644)


without that 2nd line, patchwork's checker gives me this:

-:164: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'fsname' - possible
side-effects?
#164: FILE: include/linux/dynamic_debug.h:291:
+#define DEFINE_DYNAMIC_DEBUG_CLASSBITS(fsname, _var, _flgs, desc, ...) \
+ MODULE_PARM_DESC(fsname, desc); \
+ static struct dyndbg_classbits_param ddcats_##_var = { \
+ .bits = &(_var), \
+ .flags = _flgs, \
+ .classes = { __VA_ARGS__, _DPRINTK_SITE_UNCLASSED } \
+ }; \
+ module_param_cb(fsname, _ops_dyndbg_classbits, \
+ _##_var, 0644)

with it I get compile err - suggesting this was a terrible guess at a fix.

 from
/home/jimc/projects/lx/wk-next/drivers/gpu/drm/drm_print.c:28:
/home/jimc/projects/lx/wk-next/drivers/gpu/drm/drm_print.c:57:32:
error: ‘debug’ undeclared here (not in a function); did you mean
‘_ddebug’?
   57 | DEFINE_DYNAMIC_DEBUG_CLASSBITS(debug, __drm_debug, "p",
  |^
/home/jimc/projects/lx/wk-next/include/linux/dynamic_debug.h:283:21:
note: in definition of macro ‘DEFINE_DYNAMIC_DEBUG_CLASSBITS’
  283 | __typeof__ (_fsname) fsname = _fsname;
 \
  | ^~~
make[3]: *** [/home/jimc/projects/lx/wk-next/scripts/Makefile.build:288:
drivers/gpu/drm/drm_print.o]




that patchset has another case, similarly confusing:

#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \
 DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \
 if (DYNAMIC_DEBUG_BRANCH(id)) \
  func(, ##__VA_ARGS__); \
 } while (0)

that macro is a simple extension of an existing macro,
which also would suffer this warning.

if I insert this at line 2:

__typeof__ (id) __id = (id); \

I get this:

  | ^~~~
/home/jimc/projects/lx/linux.git/include/linux/dynamic_debug.h:230:25:
note: previous definition of ‘__id’ with type ‘int’
  230 | __typeof__ (id) __id = (id);\
  | ^~~~
/home/jimc/projects/lx/linux.git/include/linux/dynamic_debug.h:260:9:
note: in expansion of macro ‘__dynamic_func_call_cls’
  260 | __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt,
func, ##__VA_ARGS__)
  | ^~~


one side thinks its an int, other side sees a struct _ddebug * pointer


any hints on how to fix these so patchset it submittable ?


thanks
jimc

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: adding GCC optimze O0 to early_fixmap_init causes compiler error (BUILD_BUG failed)

2022-01-23 Thread jim . cromie
On Sun, Jan 23, 2022 at 4:23 AM Chan Kim  wrote:
>
> Hello all,
>
> In linux 5.4.21, when tell the compiler to use no optimzation for function 
> early_fixmap_init as below,
>
> (I need to compile with O0 to follow what’s happening here using gdb.)
>
> #pragma GCC push_options
>
> #pragma GCC optimze ("O0")
>
> void __init early_fixmap_init(void)
>
> {
>
> ...
>
> }
>
> #pragma GCC pop_options
>
>
>
> I get this compiler error below. (make ARCH=arm64 
> CROSS_COMPILE=aarch64-none-elf- Image -j24)
>
> CALLscripts/atomic/check-atomics.sh
>
>   CALLscripts/checksyscalls.sh
>
>   CHK include/generated/compile.h
>
>   CC  arch/arm64/mm/mmu.o
>
>   CC  drivers/irqchip/irq-gic-v3.o
>
> In file included from ./include/linux/build_bug.h:5,
>
>  from ./arch/arm64/include/asm/sysreg.h:758,
>
>  from ./arch/arm64/include/asm/cputype.h:126,
>
>  from ./arch/arm64/include/asm/cache.h:8,
>
>  from ./include/linux/cache.h:6,
>
>  from arch/arm64/mm/mmu.c:9:
>
> ./arch/arm64/include/asm/pgalloc.h: In function '__pgd_populate.constprop':
>
> ./include/linux/compiler.h:350:38: error: call to '__compiletime_assert_88' 
> declared with attribute error: BUILD_BUG failed
>
>   350 |  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>
>   |  ^
>
> ./include/linux/compiler.h:331:4: note: in definition of macro 
> '__compiletime_assert'
>
>   331 |prefix ## suffix();\
>
>   |^~
>
> ./include/linux/compiler.h:350:2: note: in expansion of macro 
> '_compiletime_assert'
>
>   350 |  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>
>   |  ^~~
>
> ./include/linux/build_bug.h:39:37: note: in expansion of macro 
> 'compiletime_assert'
>
>39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>
>   | ^~
>
> ./include/linux/build_bug.h:59:21: note: in expansion of macro 
> 'BUILD_BUG_ON_MSG'
>
>59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
>
>   | ^~~~
>
> ./arch/arm64/include/asm/pgalloc.h:88:2: note: in expansion of macro 
> 'BUILD_BUG'
>
>88 |  BUILD_BUG();
>
>   |  ^
>
> make[2]: *** [scripts/Makefile.build:265: arch/arm64/mm/mmu.o] Error 1
>
> make[1]: *** [scripts/Makefile.build:509: arch/arm64/mm] Error 2
>
> make: *** [Makefile:1652: arch/arm64] Error 2
>
> make: *** Waiting for unfinished jobs
>
>   AR  drivers/irqchip/built-in.a
>
> AR  drivers/built-in.
>
>
>
> What does this mean and what should I do?
>

it means that some precondition failed, and you reached a known broken setup.
Instead of giving you a broken kernel, its told you that you have to
fix this 1st.

try making an intermediate output, forex:
make init/main.i

that should provide hints as to how you got to the BUILD_BUG

I dont think banging on -O compile options will help,
at least not after seeing GregKH opine on it.

> Thanks!
>
> Chan Kim
>
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: About the kernel configuration(CONFIG_CPU_FREQ and CONFIG_CPU_IDLE.)

2022-01-21 Thread jim . cromie
On Tue, Jan 18, 2022 at 6:23 PM 孙世龙 sunshilong  wrote:
>
> Hi, list
> I am using Linux 5.4.78 with PREEMPT_RT patch.
> Hardware name: UNO-2372G-J021AE.
>
> It's strange that the frequency of the CPU is not constant(i.e.
> not fixed at a specific frequency) if I both disable CONFIG_CPU_FREQ
> and CONFIG_CPU_IDLE
> whereas
> the frequency of the CPU is constant if I only disable CONFIG_CPU_FREQ
> (leave CONFIG_CPU_IDLE enabled).
>
> Could somebody please shed some light on this matter?

just a WAG, but

lower power draw has been hugely important for years,
nobody would sacrifice that for "simplicity", such a feature would be unused.
I could imagine enterprise SMM bios disallowing such operation.

On dozens of processors over time, TSC has been marked unstable
by the kernel, Id suppose that signals a certain distrust of some clocks.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Any tracing mechanism can track the executed instructions of a user process in the kernel?

2021-10-18 Thread jim . cromie
On Sun, Oct 17, 2021 at 8:46 PM Dongliang Mu  wrote:
>
> Hi all,
>
> I am writing to kindly ask one question: is there any tracing
> mechanism in Linux kernel that can trace all the executed instructions
> of a user process? If this user process is run on different
> processors, traces of this process on different processors should be
> also recorded.
>
> Any comment is welcome.
>

take a look at rr-project.org

what rr does

rr aspires to be your primary C/C++ debugging tool for Linux,
replacing — well, enhancing — gdb. You record a failure once, then
debug the recording, deterministically, as many times as you want. The
same execution is replayed every time.

rr also provides efficient reverse execution under gdb. Set
breakpoints and data watchpoints and quickly reverse-execute to where
they were hit.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: error: impossible constraint in 'asm' when compiling kernel code with -O0 option

2021-10-07 Thread jim . cromie
On Tue, Oct 5, 2021 at 9:00 PM  wrote:
>
> In linux-5.4.21 code,
>
> To prevent some variables from being ‘optimized out’ during kernel code 
> analysis using gdb, I added in drivers/iommu/Makefile,
>
> (replacing -O2 flags to -O0 flags for some files,  I found 
> http://www.joelfernandes.org/linux/2018/06/10/kernel-gdb.html )
>
> CFLAGS_REMOVE_arm-smmu.o := -O2
>
> CFLAGS_REMOVE_arm-smmu-impl.o := -O2
>
> CFLAGS_REMOVE_io-pgtable-arm-v7s.o := -O2
>
> CFLAGS_REMOVE_io-pgtable-arm.o := -O2
>
> CFLAGS_REMOVE_of_iommu.o := -O2
>
> CFLAGS_REMOVE_arm-smmu-v3.o := -O2
>
> CFLAGS_arm-smmu.o := -O0
>
> CFLAGS_arm-smmu-impl.o := -O0
>
> CFLAGS_io-pgtable-arm-v7s.o := -O0
>
> CFLAGS_io-pgtable-arm.o := -O0
>
> CFLAGS_of_iommu.o := -O0
>
> CFLAGS_arm-smmu-v3.o := -O0
>
> But when I do make ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- Image, I get
>
> CALLscripts/checksyscalls.sh
>
>   CALLscripts/atomic/check-atomics.sh
>
>   CHK include/generated/compile.h
>
>   CC  drivers/iommu/io-pgtable-arm.o
>

try
make   drivers/iommu/io-pgtable-arm.i
it will show you intermediate output.

I did it on kernel/params.i  ( wrong config to run yours)

you will find the asm goto code therein

[jimc@samwise lm-sept]$ less +/jump_label kernel/params.i

# 53 "/home/jimc/projects/lx/wk-next/arch/x86/include/asm/jump_label.h"
static inline __attribute__((__gnu_inline__))
__attribute__((__unused__)) __attribute__((no_instrument_function))
__attribute__((__always_inline__)) boo
l arch_static_branch_jump(struct static_key * const key, const bool branch)
{
 do { asm goto("1:" "jmp %l[l_yes]\n\t" ".pushsection __jump_table,
\"aw\" \n\t" " " ".balign 8" " " "\n\t" ".long 1b - . \n\t" ".long
%l[l_yes] - . \n
\t" " " ".quad" " " "%c0 + %c1 - .\n\t" ".popsection \n\t" : : "i"
(key), "i" (branch) : : l_yes); asm (""); } while (0)


 ;

 return false;
l_yes:
 return true;
}

extern int arch_jump_entry_size(struct jump_entry *entry);
# 118 "/home/jimc/projects/lx/wk-next/include/linux/jump_label.h" 2

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: advice on checkpatch error

2021-10-05 Thread jim . cromie
On Tue, Oct 5, 2021 at 1:14 PM  wrote:
>
> so I have this macro, with some helpers,
> the helper gets a checkpatch error.
>
> DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug,
> "i915/gvt bitmap desc",
> /* map each bit to a category */
> _DD_cat_(0, "gvt:cmd:"),
> _DD_cat_(1, "gvt:core:"),
> _DD_cat_(2, "gvt:dpy:"),
> _DD_cat_(3, "gvt:el:"),
> _DD_cat_(4, "gvt:irq:"),
> _DD_cat_(5, "gvt:mm:"),
> _DD_cat_(6, "gvt:mmio:"),
>
>
> +#if defined(CONFIG_DYNAMIC_DEBUG) || \
> +   (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
> +/**
> + * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized prdbgs
> + * @fsname: parameter basename under /sys
> + * @_var:C-identifier holding bitmap
> + * @desc:  string summarizing the controls provided
> + * @...:list of struct dyndbg_bitdesc initializations
> + *
> + * Intended for modules with substantial use of "categorized" prdbgs
> + * (those with some systematic prefix in the format string), this lets
> + * modules using pr_debug to control them in groups according to their
> + * format prefixes, and map them to bits 0-N of a sysfs control point.
> + * Each @... gives the index and prefix map.
> + */
> +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...)   \
> +   MODULE_PARM_DESC(fsname, desc); \
> +   static struct dyndbg_bitmap_param ddcats_##_var =   \
> +   { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}};   \
> +   module_param_cb(fsname, _ops_dyndbg, _##_var, 0644)
> +
> +/* helper macros provide combos of '^' anchor and ' ' postfix */
> +#define _DD_cat_(N, str)   [N] = { .match = str " " }
> +#define _DD_cats_(N, str)  [N] = { .match = str }
> +#define _DD_pfx_(N, str)   [N] = { .match = "^" str " " }
> +#define _DD_pfxs_(N, str)  [N] = { .match = "^" str }
> +
>
> ERROR: space prohibited before open square bracket '['
> #250: FILE: include/linux/dynamic_debug.h:273:
> +#define _DD_cat_(N, str) [N] = { .match = str " " }
>
> Ive tried various (encapsulations) to no avail.
>
> what am I missing ?

I'll just do it more like this ...

static const struct intel_step_info kbl_revids[] = {
[1] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
[2] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
[3] = { .gt_step = STEP_D0, .display_step = STEP_B0 },
[4] = { .gt_step = STEP_F0, .display_step = STEP_C0 },
[5] = { .gt_step = STEP_C0, .display_step = STEP_B1 },
[6] = { .gt_step = STEP_D1, .display_step = STEP_B1 },
[7] = { .gt_step = STEP_G0, .display_step = STEP_C0 },
};

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


advice on checkpatch error

2021-10-05 Thread jim . cromie
so I have this macro, with some helpers,
the helper gets a checkpatch error.

DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug,
"i915/gvt bitmap desc",
/* map each bit to a category */
_DD_cat_(0, "gvt:cmd:"),
_DD_cat_(1, "gvt:core:"),
_DD_cat_(2, "gvt:dpy:"),
_DD_cat_(3, "gvt:el:"),
_DD_cat_(4, "gvt:irq:"),
_DD_cat_(5, "gvt:mm:"),
_DD_cat_(6, "gvt:mmio:"),


+#if defined(CONFIG_DYNAMIC_DEBUG) || \
+   (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
+/**
+ * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized prdbgs
+ * @fsname: parameter basename under /sys
+ * @_var:C-identifier holding bitmap
+ * @desc:  string summarizing the controls provided
+ * @...:list of struct dyndbg_bitdesc initializations
+ *
+ * Intended for modules with substantial use of "categorized" prdbgs
+ * (those with some systematic prefix in the format string), this lets
+ * modules using pr_debug to control them in groups according to their
+ * format prefixes, and map them to bits 0-N of a sysfs control point.
+ * Each @... gives the index and prefix map.
+ */
+#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...)   \
+   MODULE_PARM_DESC(fsname, desc); \
+   static struct dyndbg_bitmap_param ddcats_##_var =   \
+   { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}};   \
+   module_param_cb(fsname, _ops_dyndbg, _##_var, 0644)
+
+/* helper macros provide combos of '^' anchor and ' ' postfix */
+#define _DD_cat_(N, str)   [N] = { .match = str " " }
+#define _DD_cats_(N, str)  [N] = { .match = str }
+#define _DD_pfx_(N, str)   [N] = { .match = "^" str " " }
+#define _DD_pfxs_(N, str)  [N] = { .match = "^" str }
+

ERROR: space prohibited before open square bracket '['
#250: FILE: include/linux/dynamic_debug.h:273:
+#define _DD_cat_(N, str) [N] = { .match = str " " }

Ive tried various (encapsulations) to no avail.

what am I missing ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: List of all available kernel modules per version

2021-09-26 Thread jim . cromie
On Fri, Sep 24, 2021 at 9:32 PM Valdis Klētnieks
 wrote:
>
> On Fri, 24 Sep 2021 18:08:01 -0600, jim.cro...@gmail.com said:
>
> > grumble/
> > ive often wanted lsmod -b  to tell me that list.  or something like that.
> > maybe a different rc
>
> See CONFIG_ICONFIG and friends in init/Kconfig
>
> That will give you not just the module list, but the entire .config the 
> kernel was built with.

Indeed.  I use it builtin, when I remember to add it.
And annoying when Ive forgotten it.

and its nowhere near default:
/boot/config-5.13.15-200.fc34.x86_64:# CONFIG_IKCONFIG is not set


For a while now, Ive wanted a way to feed a config-fragment,
say a dozen CONFIG specs;  CONFIG_IKCONFIG=y, CONFIG_DYNAMIC_DEBUG=y, etc...
and have it all just work

I would note that virtme does something comparable:

[jimc@frodo local-i915m]$ virtme-configkernel --update
  GEN Makefile
.config:7395:warning: override: reassigning to symbol UEVENT_HELPER
.config:7396:warning: override: reassigning to symbol VIRTIO
.config:7397:warning: override: reassigning to symbol VIRTIO_PCI
.config:7398:warning: override: reassigning to symbol VIRTIO_MMIO
.config:7399:warning: override: reassigning to symbol NET
.config:7400:warning: override: reassigning to symbol NET_CORE

though it gives ~53 such msgs to stderr,
it just works, so I havent really looked under the hood,
at why those are warnings.
Rerunning gets the same warnings again,
so its not reflective of actual changes, just potential ones

Is there a way to do something like this ?
   make defconfig modconfig -DCONFIG_IKCONFIG=y
   make defconfig modconfig -from=./local-config-customizations

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how to avoid CPU watchdog error during debug

2021-09-25 Thread jim . cromie
On Sun, Aug 29, 2021 at 7:46 PM  wrote:
>
>
> >
> > since many things are time depending in the kernel it is difficult to stop
> > parts of the kernel. The question is if it is really absolutely necessary
> > to do this? Why you can not do it by logging with printk?
> >
> > Debugging is described in:
> > https://www.doc-developpement-durable.org/file/Projets-
> > informatiques/cours-&-manuels-
> > informatiques/Linux/Linux%20Kernel%20Development,%203rd%20Edition.pdf
> >
> > See Chapter 18 Debugging
> >
> > Thanks! Bye Philipp
> >
> Hi, Philipp,
> I've found your answer too late. Thanks for the info(I learned something
> about the early_prink from the book).
> Actually, shortly after I sent my question, I learned how to make printk
> appear in the console (not in the dmesg buffer) and was using it.
> (I added the line "kernel.prink = 5 4 1 7" in the /etc/sysctl.conf file.
> So I've set the default console log level to 5 making default printk appear
> in the console.)
> Thanks!
>
> Chan


thanks for the followup

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Device doesnt show up on Ble Scanner - gatt-service example in tools folder as per Documentation(doc)

2021-09-25 Thread jim . cromie
On Tue, Aug 31, 2021 at 2:41 AM Raul Piper  wrote:
>
> On Tue, Aug 31, 2021 at 12:08 PM Luiz Augusto von Dentz
>  wrote:
> >
> > Hi Raul,
> >
> Hello Luiz,
> > On Mon, Aug 30, 2021 at 11:32 PM Raul Piper  wrote:
> > >
> > > Any inputs on this?
> >
> > Did you remember to advertise? I mean those only services but it
> > doesn't necessarily advertise which is something perhaps could be
> > updated on those samples so they become visible on the scanners.
> >
> Isnt ./gatt-service supposed to advertise as well?
> I cross built and rant ./advtest with -h and it gave not much information :
> ./advtest --h
> advtest - Advertising testing
> Usage:
> advtest [options]
>
> and when I ran
> ./advtest
> it gave : At least 2 controllers are required
> what other input does it take ? hci0?hci1?
>
> when i try to run ./advtest -hci0
> it gave :  Invalid command line parameters
>
>  i tried to find bt controllers on my board and it gave :
>
> hcitool dev
> Devices :
>
> It gave nothing.
>
> Any idea how to proceed ?I suspect I need to enable the hci controller
> or something?
> But it is strange that ./gatt-service did not throw any error and
> registered the services without any error?shouldn't  these examples
> check for the ble controller first before proceeding further?
>
>
> > > On Sun, Aug 29, 2021 at 11:42 PM Raul Piper  
> > > wrote:
> > > >
> > > > Hello,
> > > > I tried cross compiling the bluez and ported it to my linux platform.I
> > > > think i have done it correctly as I am able to launch the gatt-service
> > > > example successfully but i am not able to view it on the Smartphone
> > > > app - blescanner or light blue.
> > > >
> > > > Below are the logs :
> > > > ===
> > > > ./gatt-service
> > > > gatt-service unique name: :1.18
> > > > Registered service: /service1
> > > > Registered service: /service2
> > > > Registered service: /service3
> > > > Get Primary: True
> > > > Get UUID: 1802--1000-8000-00805f9b34fb
> > > > Exist Includes: 1802--1000-8000-00805f9b34fb
> > > > Get Includes: 1802--1000-8000-00805f9b34fb
> > > > Includes path: /service3
> > > > Get Includes: /service2
> > > > Characteristic(2a06--1000-8000-00805f9b34fb): Get("Value")
> > > > Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value")
> > > > Get Primary: True
> > > > Get UUID: A00C
> > > > Exist Includes: A00C
> > > > Characteristic(2c07--1000-8000-00805f9b34fb): Get("Value")
> > > > Descriptor(): Get("Value")
> > > > Get Primary: True
> > > > Get UUID: A00D
> > > > Exist Includes: A00D
> > > > Characteristic(2b06--1000-8000-00805f9b34fb): Get("Value")
> > > > Descriptor(0260c653-1a54-426b-9e36-e84c238bc669): Get("Value")
> > > >
> > > >
> > > >
> > > > I also tried to run the python example inside test/example-gatt-server
> > > > but again I am not able to view the device name.
> > > >
> > > > Below are the logs :
> > > > ===
> > > > python3 example-gatt-server
> > > > example-gatt-server:395: PyGIDeprecationWarning: GObject.timeout_add
> > > > is deprecated; use GLib.timeout_add instead
> > > >   GObject.timeout_add(5000, self.drain_battery)
> > > > example-gatt-server:652: PyGIDeprecationWarning: GObject.MainLoop is
> > > > deprecated; use GLib.MainLoop instead
> > > >   mainloop = GObject.MainLoop()
> > > > Registering GATT application...
> > > > GetManagedObjects
> > > > GATT application registered
> > > >
> > > > I even opened the btmon on a different tab but still I am not able to
> > > > see anything on that.
> > > > Is there any other application we have to run?
> > > > Has any one ran  it successfully and able to view/connect and see all
> > > > the 3 services it is advertising.
> > > >
> > > > Please advise / ask for any further information , I will provide.
> > > >
> > > > Thanks in advance !
> > > >
> > > > Regards,
> > > > R
> >
> >
> >
> > --
> > Luiz Augusto von Dentz
>


any progress ?
this thread looked promising...

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: where can I find the explanations for pin-ctrl or #clock-cells in the dts file? (device tree)

2021-09-25 Thread jim . cromie
On Fri, Sep 17, 2021 at 5:53 AM  wrote:
>
> Hi
>
> I’ve downloaded device tree spec from 
> https://www.devicetree.org/specifications/ but it doesn’t tell me anything 
> about #clock-cells or pin-ctrl properties. (the spec is the newst 2020 
> version)
>
> Isnt there any full specification somewhere?

that link looks like the place to start / stay - there is a mailing
list mentioned, and a github repo

Id suggest you find the spot in the docs where you think the
properties should be,
add the skeleton definitions, with your own best guess, and a  YOUR
EXPERTISE HERE marker,
and invite some expertise.

1st step, pull the repo, grep -r for pin-ctrl, in a few different spellings,
and see what comes up.

>
> Thanks,
>
> Chan Kim
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: List of all available kernel modules per version

2021-09-24 Thread jim . cromie
On Thu, Sep 23, 2021 at 4:05 PM Valdis Klētnieks
 wrote:
>
> On Thu, 23 Sep 2021 18:39:22 +0200, Leon Gross said:
> > If got more of a general question: Is there a way to list all the
> > standard kernel modules that are included in a specific kernel version?
> > And I don't meant the currently running modules I could get via lsmod
> > but I mean all the modules that are supported by a specific kernel version.
> > Or can I even derive these myself from the source tree, without even
> > compiling the kernel (that would be very helpful)?
>
> One thing that you're overlooking is that many "modules" can be builtin
> to the kernel rather than modprobed at runtime.
>
> So it really depends what problem you're trying to solve by enumerating
> all the modules.
>

grumble/
ive often wanted lsmod -b  to tell me that list.  or something like that.
maybe a different rc

[jimc@samwise wk-next]$ grep -P \\bparams /proc/dynamic_debug/control
kernel/params.c:177 [params]parse_args =_ "doing %s, parsing ARGS: '%s'\012"
kernel/params.c:156 [params]parse_one =_ "Unknown argument '%s'\012"
kernel/params.c:152 [params]parse_one =_ "doing %s: %s='%s'\012"
kernel/params.c:139 [params]parse_one =_ "handling %s with %p\012"
[jimc@samwise wk-next]$ modprobe params
modprobe: FATAL: Module params not found in directory
/lib/modules/5.15.0-rc2-sept
[jimc@samwise wk-next]$ echo $?
1

I guess it comes down to whats in /proc/

[jimc@samwise wk-next]$ wc /proc/modules
133 798 7818 /proc/modules
[jimc@samwise wk-next]$ lsmod | wc
134 4716170

or is it (lsmod user prog) already scouring /sys/module (via lib Id presume)?
it seems that
/sys/modules/* minus col-1-of  /proc/modules
would tell builtins

just musing out loud...

> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: ALSA kernel projects - for academic purposes

2021-09-24 Thread jim . cromie
On Fri, Sep 24, 2021 at 11:53 AM Muni Sekhar  wrote:
>
> On Fri, Sep 24, 2021 at 10:46 PM  wrote:
> >
> > On Fri, Sep 24, 2021 at 10:58 AM Muni Sekhar  
> > wrote:
> > >
> > > On Fri, Sep 24, 2021 at 10:02 PM Valdis Klētnieks
> > >  wrote:
> > > >
> > > > On Fri, 24 Sep 2021 19:34:59 +0530, Muni Sekhar said:
> > > > > What small projects would you suggest to a novice with the ALSA
> > > > > kernel. The aim is to develop a familiarity with the ALSA kernel
> > > > > source code, and also to submit it for academic purposes.
> > > >
> > > > A good place to start is getting a good handle on what the phrase "the 
> > > > ALSA
> > > > kernel" even means.
> > > Basically looking for kernel space audio subsystem projects rather
> > > than its user-space library(alsa-lib) and utilities(alsa-utils).
> >
> > why ?
> > if your interest is better sound, then improving user-space is going
> > to be more productive.
> >
> > also, theres now pipewire, which is new, and all the buzz.
> > its apparently the future of linux audio
> Sounds interesting. Could you please give few more pointers on how to
> start on pipewire project.
> >

https://pipewire.org/

you know everything I do now

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: ALSA kernel projects - for academic purposes

2021-09-24 Thread jim . cromie
On Fri, Sep 24, 2021 at 10:58 AM Muni Sekhar  wrote:
>
> On Fri, Sep 24, 2021 at 10:02 PM Valdis Klētnieks
>  wrote:
> >
> > On Fri, 24 Sep 2021 19:34:59 +0530, Muni Sekhar said:
> > > What small projects would you suggest to a novice with the ALSA
> > > kernel. The aim is to develop a familiarity with the ALSA kernel
> > > source code, and also to submit it for academic purposes.
> >
> > A good place to start is getting a good handle on what the phrase "the ALSA
> > kernel" even means.
> Basically looking for kernel space audio subsystem projects rather
> than its user-space library(alsa-lib) and utilities(alsa-utils).

why ?
if your interest is better sound, then improving user-space is going
to be more productive.

also, theres now pipewire, which is new, and all the buzz.
its apparently the future of linux audio


> >
> > There's the Linux kernel, a small corner of which is the ALSA subsystem for
> > sound.
> >
>
>
> --
> Thanks,
> Sekhar
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: thrashing on format %u vs size_t arg

2021-09-15 Thread jim . cromie
On Tue, Sep 14, 2021 at 10:47 PM Bernd Petrovitsch
 wrote:
>
> On 15/09/2021 00:38, jim.cro...@gmail.com wrote:
> > I will cast and be done with it
>
> Or you use - like everyone else - "%zu" as format
> specifier.
>
> Read `man 3 printf` for more - the Kernel's printk
> implements almost all of it.
>

thank you, Id never seen %zu.
failure of imagination I guess.


> [ Fullquote deleted - please don't do that ]
>

I dont understand this -
I did top-post (using my phone, not "native" email, mea culpa)
but thats not what you said ..
are you against tail-trimming emails in reply ?

again, thanks

> MfG,
> Bernd
> --
> Bernd Petrovitsch  Email : be...@petrovitsch.priv.at
>   There is NO CLOUD, just other people's computers. - FSFE
>   LUGA : http://www.luga.at

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: thrashing on format %u vs size_t arg

2021-09-14 Thread jim . cromie
I will cast and be done with it

On Tue, Sep 14, 2021, 1:39 PM Valdis Klētnieks 
wrote:

> On Tue, 14 Sep 2021 09:32:33 -0600, jim.cro...@gmail.com said:
>
> > Im getting what appears to be conflicting warnings
> > about %u vs unsigned int (sometimes unsigned long int)
> > depending upon platform ??
>
> Hint:  What size is a size_t on a 32 bit platform, and on a 64 bit
> platform?
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


thrashing on format %u vs size_t arg

2021-09-14 Thread jim . cromie
wrt:

+   v2pr_info("read %u bytes from userspace <\n%s>\n", len, tmpbuf);

Im getting what appears to be conflicting warnings
about %u vs unsigned int (sometimes unsigned long int)
depending upon platform ??

Ive now tried both  %lu  and  %u

What have I missed ?




[jimc:dd-drm-next 3/16] lib/dynamic_debug.c:786:53: warning: format
specifies type 'unsigned int' but the argument has type 'size_t' (aka
'unsigned long')

head:   bf8f0832d11f09c546179ca6a2c5432706ea3d32



[kbuild-all] [jimc:dd-drm-next 3/16] include/linux/kern_levels.h:5:25:
warning: format '%u' expects argument of type 'unsigned int', but
argument 2 has type 'size_t' {aka 'long unsigned int'}

Inbox
Linux/kbuild-all
to-me

kernel test robot via lists.01.org

Mon, Sep 13, 9:08 PM (11 hours ago)
to me, kbuild-all
tree:   https://github.com/jimc/linux.git dd-drm-next
head:   bf8f0832d11f09c546179ca6a2c5432706ea3d32
commit: 221a341c10ebb8545beac6ee3937859d26ddcc60 [3/16] dyndbg:
rationalize verbosity
config: alpha-allyesconfig (attached as .config)


kernel test robot

Sep 13, 2021, 5:45 AM (1 day ago)
to me
tree/branch: https://github.com/jimc/linux.git dd-drm-next
branch HEAD: 02a6c357b6a5eb02cc6b2ceb5a7a93c809388ae0  nouveau: fold
multiple DRM_DEBUG_DRIVERs together

Error/Warning in current branch:

lib/dynamic_debug.c:786:54: warning: format specifies type 'unsigned
long' but the argument has type 'size_t' (aka 'unsigned int')
[-Wformat]
lib/dynamic_debug.c:864:54: warning: format specifies type 'unsigned
long' but the argument has type 'size_t' (aka 'unsigned int')
[-Wformat]
lib/dynamic_debug.c:876:54: warning: format specifies type 'unsigned
long' but the argument has type 'size_t' (aka 'unsigned int')
[-Wformat]


[jimc:dd-drm-next 3/16] lib/dynamic_debug.c:786:54: warning: format
specifies type 'unsigned long' but the argument has type 'size_t' (aka
'unsigned int')

Inbox
Linux/kbuild-all
to-me

kernel test robot

Sep 11, 2021, 5:17 PM (3 days ago)
to me, kbuild-all
tree:   https://github.com/jimc/linux.git dd-drm-next
head:   02a6c357b6a5eb02cc6b2ceb5a7a93c809388ae0
commit: 74992de06222ed51caed07800e291e68eb4a627e [3/16] dyndbg:
rationalize verbosity
config: hexagon-randconfig-r034-20210911 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project
261cbe98c38f8c1ee1a482fe7650e790f58a)

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how to properly use BUILD_BUG_ON_MSG ?

2021-08-30 Thread jim . cromie
trimming out the "noise", Im left with

>39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>   | ^~
> /home/jimc/projects/lx/wk-next/include/linux/dynamic_debug.h:283:9:
> note: in expansion of macro ‘BUILD_BUG_ON_MSG’
>   283 | BUILD_BUG_ON_MSG(1, "you need -DDYNAMIC_DEBUG_MODULE
> in compile")
>   | ^~~~
> /home/jimc/projects/lx/wk-next/drivers/gpu/drm/drm_print.c:60:1: note:
> in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_CATEGORIES’
>60 | DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug, __drm_debug,
>   | ^~~
>
>
>


So, following that advice, I added

--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -20,6 +20,9 @@ drm-y   :=drm_aperture.o drm_auth.o drm_cache.o \
drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o \
drm_managed.o drm_vblank_work.o

+#ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG
+ccflags-y += -DDYNAMIC_DEBUG_MODULE
+#endif
 drm-$(CONFIG_DRM_LEGACY) += drm_agpsupport.o drm_bufs.o drm_context.o
drm_dma.o \


that fixed the error, and makes the BUILD_BUG usage look good.

so I withdraw the question

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


how to properly use BUILD_BUG_ON_MSG ?

2021-08-30 Thread jim . cromie
so I got this macro which depends upon config choices to work,

Id like to have alt-config versions which throw some obvious error.

like this:

#elif (defined(CONFIG_DYNAMIC_DEBUG_CORE) && !defined(DYNAMIC_DEBUG_MODULE))

#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, var, bitmap_desc, ...) \
BUILD_BUG_ON_MSG(1, "you need -DDYNAMIC_DEBUG_MODULE in compile")

#else
...


is that more or less the expected usage ?
the error messages seem less clear than Id like,
leading me to suspect poor usage, or a better way to do it.


/home/jimc/projects/lx/wk-next/include/linux/compiler_types.h:310:11:
error: expected identifier or ‘(’ before ‘while’
  310 | } while (0)
  |   ^
/home/jimc/projects/lx/wk-next/include/linux/compiler_types.h:316:9:
note: in expansion of macro ‘__compiletime_assert’
  316 | __compiletime_assert(condition, msg, prefix, suffix)
  | ^~~~
/home/jimc/projects/lx/wk-next/include/linux/compiler_types.h:328:9:
note: in expansion of macro ‘_compiletime_assert’
  328 | _compiletime_assert(condition, msg,
__compiletime_assert_, __COUNTER__)
  | ^~~
/home/jimc/projects/lx/wk-next/include/linux/build_bug.h:39:37: note:
in expansion of macro ‘compiletime_assert’
   39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
  | ^~
/home/jimc/projects/lx/wk-next/include/linux/dynamic_debug.h:283:9:
note: in expansion of macro ‘BUILD_BUG_ON_MSG’
  283 | BUILD_BUG_ON_MSG(1, "you need -DDYNAMIC_DEBUG_MODULE
in compile")
  | ^~~~
/home/jimc/projects/lx/wk-next/drivers/gpu/drm/drm_print.c:60:1: note:
in expansion of macro ‘DEFINE_DYNAMIC_DEBUG_CATEGORIES’
   60 | DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug, __drm_debug,
  | ^~~










#if defined(CONFIG_DYNAMIC_DEBUG) || \
(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
/**
 * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized prdbgs
 * @fsname: parameter basename under /sys
 * @var:C-identifier holding bitmap
 * @_desc:  string summarizing the controls provided
 * @...:list of struct dyndbg_bitdesc initializations
 *
 * Intended for modules with substantial use of "categorized" prdbgs
 * (those with some systematic prefix in the format string), this lets
 * modules (using dyndbg) control those prdbg groups according to
 * their prefixes, and map them to bits 0-N of a sysfs control point.
 * The @bits... identifies the prefixes to be used by dyndbg to
 * select and alter those categorized prdbgs, order defines bitpos.
 */
#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, _desc, ...) \
MODULE_PARM_DESC(fsname, _desc); \
static struct dyndbg_bitmap_param ddcats_##_var = \
{ .bits = &_var, .map = { __VA_ARGS__, { .prefix = NULL }}}; \
module_param_cb(fsname, _ops_dyndbg, _##_var, 0644)

#define _DD_cat_(pfx) { .prefix = pfx, .help = "help for " pfx }
#define _DD_cat_help_(pfx) "\t   " pfx "\t- help for " pfx "\n"

extern const struct kernel_param_ops param_ops_dyndbg;

#elif (defined(CONFIG_DYNAMIC_DEBUG_CORE) && !defined(DYNAMIC_DEBUG_MODULE))

#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, var, bitmap_desc, ...) \
BUILD_BUG_ON_MSG(1, "you need -DDYNAMIC_DEBUG_MODULE in compile")

#else
#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, var, bitmap_desc, ...) \
BUILD_BUG_ON_MSG(1, "DYNAMIC_DEBUG support required to use this macro: " #var)
#define _DD_cat_(pfx)
#define _DD_cat_help_(pfx)
#endif

#endif

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: VFS: Cannot open root device "(null)" or unknown-block(0, 0): error -2

2021-08-15 Thread jim . cromie
On Sat, Aug 14, 2021 at 6:21 PM Valdis Klētnieks
 wrote:
>
> On Fri, 13 Aug 2021 18:08:38 -0600, jim.cro...@gmail.com said:
>
> > then I added BTRFS_FS, since thats the host fs.
> > of course it didnt work.
>
> > VFS: Cannot open root device "(null)" or unknown-block(0,0): error -2
> > Please append a correct "root=" boot option; here are the available 
> > partitions:
> > Kernel panic - not syncing: VFS: Unable to mount root fs on 
> > unknown-block(0,0)
> > CPU: 0 PID: 1 Comm: swapper Tainted: GW 5.14.0-rc4+ #5
>
> And it didn't find any usable btrfs (or other fs it knew about)
>
> > Heres a working  kernel (if overlarge config)
>
> > VFS: Mounted root (9p filesystem) readonly on device 0:20.
>
> > Anybody see any clues ?
>
> That '9p filesystem' should be a really big clue.  If that's the root fs that 
> you
> actually want to use, you need to do two things:
>
> a) point at it with root=
> b) have 9p filesystem support in the kernel

the part you trimmed out contained this,
I think it means I had those particular modules built-in correctly

9pnet: Installing 9P2000 support
sched_clock: Marking stable (3466602654, 29303733)->(4050551166, -554644779)
Btrfs loaded, crc32c=crc32c-generic, zoned=no
9pnet_virtio: no channels available for device /dev/root

that last line is where it skipped the track.


so I really have to understand how virtme is doing its magic.
fwiw, it looks like its somewhere in this command line

./.virtme_mods/lib/modules/0.0.0
/usr/bin/qemu-system-x86_64 -fsdev
local,id=virtfs1,path=/,security_model=none,readonly,multidevs=remap
-device virtio-9p-pci,fsdev=virtfs1,mount_tag=/dev/root -fsdev
local,id=virtfs5,path=/usr/local/lib/python3.9/site-packages/virtme-0.1.1-py3.9.egg/virtme/guest,security_model=none,readonly,multidevs=remap
-device virtio-9p-pci,fsdev=virtfs5,mount_tag=virtme.guesttools
-machine accel=kvm:tcg -watchdog i6300esb -cpu host -parallel none
-net none -echr 1 -serial none -chardev
stdio,id=console,signal=off,mux=on -serial chardev:console -mon
chardev=console -vga none -display none -kernel
./arch/x86/boot/bzImage -append
'virtme_link_mods=/home/jimc/projects/lx/wk-next/builds/local-i915m/.virtme_mods/lib/modules/0.0.0
earlyprintk=serial,ttyS0,115200 console=ttyS0 psmouse.proto=exps
"virtme_stty_con=rows 24 cols 108 iutf8" TERM=xterm-256color
rootfstype=9p rootflags=version=9p2000.L,trans=virtio,access=any,msize=200M
raid=noautodetect ro nokaslr dynamic_debug.verbose=3
module.dyndbg=+pmf init=/bin/sh -- -c "mount -t tmpfs run /run;mkdir
-p /run/virtme/guesttools;/bin/mount -n -t 9p -o
ro,version=9p2000.L,trans=virtio,access=any,msize=104857600
virtme.guesttools /run/virtme/guesttools;exec
/run/virtme/guesttools/virtme-init"' -machine dump-guest-core=on -m 2G
--smp 3
Wrong EFI loader signature.
early console in extract_kernel

btw, I will go back and look for more 9P options.
and more VIRT options

thanks

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


VFS: Cannot open root device "(null)" or unknown-block(0, 0): error -2

2021-08-13 Thread jim . cromie
Im trying to configure a minimal kernel,
that will work on a virtme / qemu / kvm stack

I did
make allnoconfig
virtme-configkernel --update

then I added BTRFS_FS, since thats the host fs.
of course it didnt work.

then tried DM, needed MD, added both,
again didnt help.

so I need to stop just guessing.
(admittedly, asking is worse ?)

heres how it actually goes:

9pnet: Installing 9P2000 support
sched_clock: Marking stable (3466602654, 29303733)->(4050551166, -554644779)
Btrfs loaded, crc32c=crc32c-generic, zoned=no
9pnet_virtio: no channels available for device /dev/root
VFS: Cannot open root device "(null)" or unknown-block(0,0): error -2
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
CPU: 0 PID: 1 Comm: swapper Tainted: GW 5.14.0-rc4+ #5
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.14.0-4.fc34 04/01/2014
Call Trace:
 dump_stack+0x1b/0x1d
 panic+0x95/0x202
 mount_block_root+0x204/0x268
 mount_root+0x5d/0x62


Heres a working  kernel (if overlarge config)

It has btrfs, md, which is why I took those guesses above

zswap: loaded using pool lzo/zbud
Key type ._fscrypt registered
Key type .fscrypt registered
Key type fscrypt-provisioning registered
Btrfs loaded, crc32c=crc32c-generic, zoned=yes
Key type encrypted registered
PM:   Magic number: 1:872:1009
RAS: Correctable Errors collector initialized.
md: Skipping autodetection of RAID arrays. (raid=autodetect will force)
qemu-system-x86_64: warning: 9p: degraded performance: a reasonable
high msize should be chosen on client/guest side (chosen msize is <=
8192). See https://wiki.qemu.org/Documentation/9psetup#msize for
details.
VFS: Mounted root (9p filesystem) readonly on device 0:20.
devtmpfs: mounted
Freeing unused decrypted memory: 2036K


Anybody see any clues ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


patch idea, kick it around here ?

2021-08-04 Thread jim . cromie
> make menuconfig

# search for something - open search dialog
/
LIB|TEST   # this works ! - thank the wizards
LIB  # this doesnt.
ACPI   # this would match 1st find by 1st line (a positive test)

its not a well-formed search pattern/regex in any system I know,
but it has an implied meaning ( grep FOO .config | grep TEST )
and utility - to see if FOO has a *TEST*, and where is it ?

Anyone want to look under the hood, see how its done ?

some UI tests:
searching '&' acts like a literal, returns no matches found
searching '|'  doesnt search, leaves u on enter-search-term dialog
nor does '|FOO'
So '|' is recognized as special

Also, the search dialog will time out,
(below is eventual response, I think on '|FOO'
but response to '|' is "the same"

─
  ┌─ Search
Results ──┐
  │ Symbol: -17 [=-17]
   │
  │ Type  : unknown
   │
  │
   │
  │
   │
  │ Symbol: 0 [=0]
   │
  │ Type  : unknown
   │

... goes on for a while


If you can find that spot in code, and make '&' special,
I think youre more than half way there.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: macro version of __func__ ?

2021-08-03 Thread jim . cromie
On Tue, Aug 3, 2021 at 1:27 PM Bernd Petrovitsch
 wrote:
>
> Hi all!
>
> On 03/08/2021 20:43, jim.cro...@gmail.com wrote:
> [...]
> > there are many uses of :
> >   pr_debug("%s ...\n", __func__, ...)
> >
> > I tried to do a preprocessor catenation to replace the runtime work,
> > but that falls afoul of the def.
>
> And that's a feature because preprocessor concatenation bloats the
> kernels memory footprint massively.
>
> [...]
> > is there a kernel macro version that would allow this "optimization" ?
>
> pr_*() are slow per se so optimizing there (apart from readability and
> size od code+data) is wasted time.

Im not after optimization per se.

but wrt it, best optimization is to not print, except when its useful.
thats the value of dyndbg, silence until you need it.

dynamic-debug lets you selectively enable pr_debug()s by their properties
- module, function, filename, lineno, format

all but last are properties of code organization,
format uniquely contains "Application" context.
in DRM context, that context could be any of DRM_UT_

If that category-info is in the format string (at compile time)
then dynamic-debug can operate on the app-info in it too.
Then dyndbg can replace drm_debug_enabled(), and save cycles.

Ive done this, Daniel Vetter liked it, so unless Im hit by a bus, I
will finish it.
https://patchwork.freedesktop.org/series/92544/

Im just looking for corner cases of its applicability.

note:  __func__ and others are available from dyndbg framework, ( +pmfl )
So callsites doing too  is "overhead" unless youre avoiding dyndbg
( memory use would be a 1st reason not to use it)

In any case, if __func__ worked like a macro, the "optimization" would
be available.

And because its in the format, this would work
echo "format  $_func_name +p" > /proc/dynamic_debug/control

of course, so would:
echo "func $_func_name +p" > /proc/dynamic_debug/control

but for that, you'd need to know func.
to get it, you could
echo  +fm > /proc/dynamic_debug/control

anyway, thats FMTYNTK

thanks
Jim

>
> MfG,
> Bernd
> --
> Bernd Petrovitsch  Email : be...@petrovitsch.priv.at
>  There is NO CLOUD, just other people's computers. - FSFE
>  LUGA : http://www.luga.at

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


macro version of __func__ ?

2021-08-03 Thread jim . cromie
hi all,

there are many uses of :
  pr_debug("%s ...\n", __func__, ...)

I tried to do a preprocessor catenation to replace the runtime work,
but that falls afoul of the def.

from gnu gcc web-page:

The identifier __func__ is implicitly declared by the translator as
if, immediately following the opening brace of each function
definition, the declaration

static const char __func__[] = "function-name";

These identifiers are variables, not preprocessor macros, and may not
be used to initialize char arrays or be concatenated with string
literals.


is there a kernel macro version that would allow this "optimization" ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


seeking guidance on adding MOD_PARAM_BITMAP

2021-07-23 Thread jim . cromie
hi folks,

I would like to add something like the following:

MOD_PARM_DYNDBG_BITMAP_DESC(__gvt_debug, "dyndbg bitmap desc",
{ "gvt: cmd: ",  "command processing" },
{ "gvt: core: ", "core help" },
{ "gvt: dpy: ",  "display help" },
{ "gvt: el: ",   "help" },
{ "gvt: irq: ",  "help" },
{ "gvt: mm: ",   "help" },
{ "gvt: mmio: ", "help" },
{ "gvt: render: ", "help" },
{ "gvt: sched: " "help" });

the point is to declaratively define an interface, a lot like:

/sys/module/drm/parameters/debug
and
$> modinfo drm
...
parm:   debug:Enable debug output, where each bit enables a
debug category.
Bit 0 (0x01)  will enable CORE messages (drm core code)
Bit 1 (0x02)  will enable DRIVER messages (drm controller code)
Bit 2 (0x04)  will enable KMS messages (modesetting code)
Bit 3 (0x08)  will enable PRIME messages (prime code)
Bit 4 (0x10)  will enable ATOMIC messages (atomic code)
Bit 5 (0x20)  will enable VBL messages (vblank code)
Bit 7 (0x80)  will enable LEASE messages (leasing code)
Bit 8 (0x100) will enable DP messages (displayport code) (int)


is there anything close to this in the kernel that I can copy & modify ?

failing that, what set of macros
(names & files they should be implemented in )
would stand some chance of surviving review ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to comment or reply to others?

2021-07-19 Thread jim . cromie
>
> For example, see this patch for your reference:
> https://lore.kernel.org/lkml/20210707055652.962-1-yao@linux.intel.com/
>
> If you then require v3 of the patch, just use the same format, copy-paste
> previous changelog data and add v3, e.g.:
>
> ---

IIUC, that line is the "snip" that  maintainer scripts (or maybe git am ?)
use to strip the extra info in the patch from the commit ?

> v3:
>  - Fixed something else
>

Any wisdom to share on content of 0/N  intro messages ?

I tend to put all -vN-1 info in 0/N, and not in 1-N/ messages,
and usually just -vN-1, -vN-2
I dont think anyone cares about what chunks got moved around while
grooming the patchset.
(which is not to say I know what Im doing...)

0/N messages dont appear to get into merge commits,
or at least not always, perhaps its a sub-tree or maintainer preference.
It does leave some ambiguity about where to explain the work;
overviews in 0/N that dont get into a merge message
leave 1..N/ under-explained.

maybe my 0/N overviews just suck. ;-)

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to comment or reply to others?

2021-07-08 Thread jim . cromie
On Sun, Jul 4, 2021 at 9:36 AM Valdis Klētnieks  wrote:
>
> On Sun, 04 Jul 2021 11:13:08 +0200, Abd-Alrhman Masalkhi said:
>
> > I have allready set up the .gitconfig file with following configuration:
> >
> > smtpEncryption = ssl
> > smtpServer = smtp.gmail.com
> > smtpUser = my-email-addr...@gmail.com
> > smtpServerPort = 465
>
> Try 'smtpEncryption = tls' instead.  Gmail's email submission servers require
> at least TLS 1.1 (current protocol version is 1.3), and they stopped allowing
> SSL (the known-insecure predecessor of TLS) some 5 years ago.
>
> https://threatpost.com/google-to-deprecate-sslv3-rc4-in-gmail-imappop-clients/118533/

I have tls, and port = 587, and an smtppass

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: laptop iwlwifi suddenly not working

2021-07-08 Thread jim . cromie
Solved !

On Fri, Jul 2, 2021 at 7:39 AM  wrote:
>
> On Thu, Jul 1, 2021 at 9:53 PM Connor Kuehl  wrote:
> >
> > Maybe there’s a hardware switch that toggles airplane mode? Might not be, 
> > since I’d think that would be kind of redundant if there’s a fn key 
> > dedicated to it, but I remember my previous laptops had a physical slider 
> > switch for airplane mode. Might be worth checking to see if your laptop has 
> > one and if it was accidentally toggled.
> >
>
> nope.  2 older laptops have that switch, but not this one.
> One of the leds on the edge is a wifi indicator,
> it turns on/off when I hit F12, they are in sync with WM-screen notifications
>
> There is a bios update, but it requires windows to install, long gone
> with dead hd.
> Im trying to download a windows iso, I'll try sticking it on a Usb and
> try booting it,
> but Im not optimistic
>
> > Connor
> >
> thanks

So, to close this out, I'll report


I found fix on toms-hardware, from 2013, for another toshiba laptop.

pull the battery and plug-power, hit the power button, to attempt turn-on
reinstall battery, boot
thats it.

heres when it was broken

[jimc@frodo ~]$ journalctl -b-1 | grep -P 'iwl|rfkill'
Jul 08 10:15:58 frodo systemd[1]: Listening on Load/Save RF Kill
Switch Status /dev/rfkill Watch.
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: Found debug
destination: EXTERNAL_DRAM
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: Found debug configuration: 0
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: loaded firmware
version 29.4063824552.0 7265D-29.ucode op_mode iwlmvm
Jul 08 10:15:58 frodo kernel: audit: type=1130
audit(1625760958.369:115): pid=1 uid=0 auid=4294967295 ses=4294967295
subj=system_u:system_r:init_t:s0 msg='unit=systemd-rfkill
comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=?
terminal=? res=success'
Jul 08 10:15:58 frodo audit[1]: SERVICE_START pid=1 uid=0
auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
msg='unit=systemd-rfkill comm="systemd" exe="/usr/lib/systemd/systemd"
hostname=? addr=? terminal=? res=success'
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: Detected Intel(R)
Dual Band Wireless AC 3165, REV=0x210
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: reporting RF_KILL
(radio disabled)
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: Applying debug
destination EXTERNAL_DRAM
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: Allocated
0x0040 bytes for firmware monitor.
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0: base HW address:
00:db:df:4e:ca:f0
Jul 08 10:15:58 frodo kernel: ieee80211 phy0: Selected rate control
algorithm 'iwl-mvm-rs'
Jul 08 10:15:58 frodo kernel: iwlwifi :07:00.0 wlp7s0: renamed from wlan0
Jul 08 10:16:02 frodo NetworkManager[883]:   [1625760962.0689]
rfkill2: found Wi-Fi radio killswitch (at
/sys/devices/pci:00/:00:1c.1/:07:00.0/ieee80211/phy0/rfkill2)
(driver iwlwifi)
Jul 08 10:16:02 frodo NetworkManager[883]:   [1625760962.0714]
manager[0x5604d91ba030]: rfkill: Wi-Fi hardware radio set enabled
Jul 08 10:16:02 frodo NetworkManager[883]:   [1625760962.0721]
manager[0x5604d91ba030]: rfkill: WWAN hardware radio set enabled
Jul 08 10:16:02 frodo NetworkManager[883]:   [1625760962.1109]
manager: rfkill: Wi-Fi disabled by radio killswitch; enabled by state
file
Jul 08 10:16:02 frodo NetworkManager[883]:   [1625760962.]
manager: rfkill: WWAN enabled by radio killswitch; enabled by state
file
Jul 08 10:16:03 frodo systemd[1]: systemd-rfkill.service: Deactivated
successfully.
Jul 08 10:16:03 frodo audit[1]: SERVICE_STOP pid=1 uid=0
auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
msg='unit=systemd-rfkill comm="systemd" exe="/usr/lib/systemd/systemd"
hostname=? addr=? terminal=? res=success'
Jul 08 10:16:13 frodo kernel: rfkill: input handler disabled
Jul 08 10:16:14 frodo gsd-media-keys[1298]: Failed to grab accelerator
for keybinding settings:rfkill
Jul 08 10:16:25 frodo kernel: rfkill: input handler enabled
Jul 08 10:16:28 frodo kernel: rfkill: input handler disabled
Jul 08 10:16:29 frodo gsd-media-keys[1965]: Failed to grab accelerator
for keybinding settings:rfkill
Jul 08 11:16:33 frodo kernel: rfkill: input handler enabled
Jul 08 11:16:33 frodo systemd[1]: systemd-rfkill.socket: Deactivated
successfully.
Jul 08 11:16:33 frodo systemd[1]: Closed Load/Save RF Kill Switch
Status /dev/rfkill Watch.
[jimc@frodo ~]$

theres a lot of rfkill toggling going on there,
but oddly in working version too, just less (not the early reported one)
other diffs might be cuz i fiddled with systemd disable rfkill, which
didnt fix it

[jimc@frodo ~]$ journalctl -b-0 | grep -P 'iwl|rfkill'
Jul 08 11:23:19 frodo systemd[1]: Listening on Load/Save RF Kill
Switch Status /dev/rfkill Watch.
Jul 08 11:23:19 frodo audit[1]: SERVICE_START pid=1 uid=0
auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
msg='unit=systemd-rfkill comm="systemd" exe="/usr/lib/systemd/systemd"
hostname=? addr=? terminal=? 

Re: How to comment or reply to others?

2021-07-03 Thread jim . cromie
On Fri, Jul 2, 2021 at 2:11 PM abdalrhman masalkhi
 wrote:
>
> Hello everyone, I am having some trouble replying to other comments, I have 
> submitted some patches and then I have received some comments from reviews, I 
> tried to reply to them by just prefixing the subject line Re: instead of 
> replying, I have posted a new thread..
> I looked into the FAQ, I have not find the answer, I have google it, and I 
> have not find any answer.. could someone please direct me to the correct 
> article which talking about replying and comment in the lkml, or give me some 
> tips!
> I would appreciate it.
>

if your messages are HTML, that might be a cause.
Many MLs will scrub those wo notice, since theyre so often spam.

This msg doesnt look like its HTML, but ...

since youre gmail, you use the web interface ? check more options at bottom



> Kind regards,
> Abdalrhman Masalkhi
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: laptop iwlwifi suddenly not working

2021-07-02 Thread jim . cromie
On Thu, Jul 1, 2021 at 9:53 PM Connor Kuehl  wrote:
>
> Maybe there’s a hardware switch that toggles airplane mode? Might not be, 
> since I’d think that would be kind of redundant if there’s a fn key dedicated 
> to it, but I remember my previous laptops had a physical slider switch for 
> airplane mode. Might be worth checking to see if your laptop has one and if 
> it was accidentally toggled.
>

nope.  2 older laptops have that switch, but not this one.
One of the leds on the edge is a wifi indicator,
it turns on/off when I hit F12, they are in sync with WM-screen notifications

There is a bios update, but it requires windows to install, long gone
with dead hd.
Im trying to download a windows iso, I'll try sticking it on a Usb and
try booting it,
but Im not optimistic

> Connor
>
thanks

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: laptop iwlwifi suddenly not working

2021-07-01 Thread jim . cromie
On Thu, Jul 1, 2021 at 3:49 PM  wrote:
>
> while fumbling to pause grub during boot,
> I think I managed to disable the wifi.
>

and booting a live usb gets same result

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


laptop iwlwifi suddenly not working

2021-07-01 Thread jim . cromie
while fumbling to pause grub during boot,
I think I managed to disable the wifi.

its affecting distro kernel, and my own

booting with iwlwifi.debug=0xff on command line
shows me

iwl_pcie_apm_init Init card's basic functions
reporting RF_KILL (radio disabled)

It is reading that from somewhere, but where ?

F12 has radio-beacon icon,
pressing it causes WM to show Airplane mode,
so that appears to be the rfr-kill switch
dmesg -w shows me bluetooth going on and off,
but no try to do so on iwlwifi
are there other rf-switches ?

I also tried reboot, F2 - (uefi bios) reset factory, reboot
that obviously didnt help

FWIW this laptop exhibits pcie correctable errors,
I have pci=noaer in my boot line to ignore it.  too long ?
iirc, it was on same pcie port
removing it doesnt help now,

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Seeking advice on "monkey patching" a driver

2021-07-01 Thread jim . cromie
On Thu, Jul 1, 2021 at 2:03 PM Ian Pilcher  wrote:
>
> On 7/1/21 12:59 PM, Greg KH wrote:
> > Oh that's horrible, please no, do not do that :)
>
> Indeed it is, but it works, and it meets my main objective, which is to
> allow the use of distribution kernel packages and modules.
>
> > How about a third option, the correct one:
> >   - submit your code changes upstream and they get merged into the
> > main kernel tree and no monkeypatching is ever needed at all!
> >
> > Have you submitted your changes upstream to the existing drivers?  What
> > is preventing that from happening today?
>
> There are a couple of reasons that I've never attempted to do this.
>
> * Scope of work - Currently, there is simply no mechanism to call an LED
> * (Probable) lack of upstream interest - As I mentioned, disk activity
>LEDs really ought to be handled by the hardware.

Are LEDs really that important?
Unless theyre rigged intrinsically into the operation, it seems tertiary



  I don't know of any
>other system that suffers from this particular limitation.  So this
>is a very, very niche use case.  (Most users of this hardware use the
>manufacturer's "firmware".)
>
>I did ask about this on the linux-ide mailing list long ago when I
>first wrote the modules, but I don't think that I ever received a
>response, which reinforces my belief that upstream isn't likely to be
>receptive.
>

theres a firehose of patches.

FWIW, now robots watch the list, and will grind your patches on lots
of configs. arches



> I've invested significant time in kernel patches in the past, only to
> see them ultimately not be accepted, so I would need to know that
> upstream was truly interested in such a feature before I would consider
> making such a commitment.
>

no guarantees, but there is staging. (here, more or less)
provisional home for code while quality develops
once youre in-tree, warts and all (to some extent, I dont know)
you may well get help (patches) improving it, surely lots of feedback.



elsewhere, nobody knows it exists.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


advice on a bisect

2021-06-29 Thread jim . cromie
I have an old 686 machine, running fedora 30
(last fedora supporting 686)

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU E7400  @ 2.80GHz
stepping : 10
microcode : 0xa0b
cpu MHz : 1614.044
cache size : 3072 KB

I generally keep it with a fresh kernel at least,

[jimc@popeye linux]$ uname -a
Linux popeye 5.13.0-rc5-j1-00030-g4c8684fe555e #210 SMP Tue Jun 15
16:56:40 MDT 2021 i686 i686 i386 GNU/Linux

recently, I found it wouldnt boot, so bisected.

[jimc@popeye linux]$ git bisect log
git bisect start
# bad: [009c9aa5be652675a06d5211e1640e02bbb1c33d] Linux 5.13-rc6
git bisect bad 009c9aa5be652675a06d5211e1640e02bbb1c33d
# good: [8124c8a6b35386f73523d27eacb71b5364a68c4c] Linux 5.13-rc4
git bisect good 8124c8a6b35386f73523d27eacb71b5364a68c4c
# good: [bd7b12aa6081c3755b693755d608f58e13798a60] Merge tag
'powerpc-5.13-5' of
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
git bisect good bd7b12aa6081c3755b693755d608f58e13798a60
# bad: [fd2cd569a4363581c00b8a2f4f26275e5562] Merge tag
'sound-5.13-rc6' of
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
git bisect bad fd2cd569a4363581c00b8a2f4f26275e5562
# good: [9bfa80df22c8cb6f9f8634693812cb958f4f] Merge tag
'regulator-fix-v5.13-rc4' of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
git bisect good 9bfa80df22c8cb6f9f8634693812cb958f4f
# bad: [cd1245d75ce93b8fd206f4b34eb58bcfe156d5e9] Merge tag
'platform-drivers-x86-v5.13-3' of
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
git bisect bad cd1245d75ce93b8fd206f4b34eb58bcfe156d5e9
# bad: [2f673816b2db30ce6122fe0e5e6a00de20e8d99a] Merge tag
'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
git bisect bad 2f673816b2db30ce6122fe0e5e6a00de20e8d99a
# bad: [368094df48e680fa51cedb68537408cfa64b788e] Merge tag
'for-linus-5.13b-rc6-tag' of
git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
git bisect bad 368094df48e680fa51cedb68537408cfa64b788e
# good: [4c8684fe555e95100030bd330d0a2780ac27952e] Merge tag
'spi-fix-v5.13-rc4' of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
git bisect good 4c8684fe555e95100030bd330d0a2780ac27952e
# good: [d4c6399900364facd84c9e35ce1540b6046c345f] vmlinux.lds.h:
Avoid orphan section with !SMP
git bisect good d4c6399900364facd84c9e35ce1540b6046c345f
# good: [374aeb91db48bb52216bb9308d611c816fb6cacb] Merge tag
'orphans-v5.13-rc6' of
git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
git bisect good 374aeb91db48bb52216bb9308d611c816fb6cacb
# good: [107866a8eb0b664675a260f1ba0655010fac1e08] xen-netback: take a
reference to the RX task thread
git bisect good 107866a8eb0b664675a260f1ba0655010fac1e08
# first bad commit: [368094df48e680fa51cedb68537408cfa64b788e] Merge
tag 'for-linus-5.13b-rc6-tag' of
git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
[jimc@popeye linux]$


after bisecting (long time, not much effort)
I booted the "bad" kernel to single user
(added 'S' to end of bootline - is this universal ?)
and poked around, so failure is more subtle than total.

by casual observation, boot hangs at dbus startup

the bad-booting kernel does manage to log its progress,
journalct -b-1 shows :

Jun 17 03:06:11 popeye kernel: Run /init as init process
Jun 17 03:06:11 popeye kernel:   with arguments:
Jun 17 03:06:11 popeye kernel: /init
Jun 17 03:06:11 popeye kernel: rhgb
Jun 17 03:06:11 popeye kernel: 2
Jun 17 03:06:11 popeye kernel:   with environment:
Jun 17 03:06:11 popeye kernel: HOME=/
Jun 17 03:06:11 popeye kernel: TERM=linux
Jun 17 03:06:11 popeye kernel: BOOT_IMAGE=/vmlinuz-5.13.0-rc6-cln

Jun 17 03:06:14 popeye systemd[1]: Started Plymouth switch root service.
Jun 17 03:06:14 popeye audit[1]: SERVICE_START pid=1 uid=0
auid=4294967295 ses=4294967295 subj=kernel msg='unit=plymouth-switch>
Jun 17 03:06:14 popeye audit[1]: SERVICE_STOP pid=1 uid=0
auid=4294967295 ses=4294967295 subj=kernel msg='unit=plymouth-switch->
Jun 17 03:06:14 popeye systemd[1]: Starting Switch Root...
Jun 17 03:06:14 popeye systemd[1]: Switching root.
Jun 17 03:06:14 popeye systemd-journald[131]: Journal stopped
Jun 17 09:06:22 popeye systemd-journald[131]: Received SIGTERM from
PID 1 (systemd).
Jun 17 09:06:22 popeye kernel: printk: systemd: 18 output lines
suppressed due to ratelimiting
Jun 17 09:06:22 popeye kernel: kauditd_printk_skb: 21 callbacks suppressed
Jun 17 09:06:22 popeye kernel: audit: type=1404
audit(1623920776.499:32): enforcing=1 old_enforcing=0 auid=4294967295
ses=42949>
Jun 17 09:06:22 popeye kernel: SELinux:  Permission watch in class
filesystem not defined in policy.
Jun 17 09:06:22 popeye kernel: SELinux:  Permission watch in class
file not defined in policy.

(at end)

Jun 17 09:06:33 popeye systemd-logind[617]: Watching system buttons on
/dev/input/event0 (Power Button)
Jun 17 09:06:33 popeye systemd-logind[617]: Watching system buttons on
/dev/input/event2 (USB USB Keykoard)
Jun 17 09:06:33 popeye 

Re: why does an in-tree loadable module taint the kernel

2021-06-16 Thread jim . cromie
On Wed, Jun 16, 2021 at 11:50 AM  wrote:
>
> On Wed, Jun 16, 2021 at 2:05 AM Greg KH  wrote:
> >
> > On Tue, Jun 15, 2021 at 12:26:19PM -0600, jim.cro...@gmail.com wrote:
> > > On Tue, Jun 15, 2021 at 10:24 AM Greg KH  wrote:
> > > >
> > > > On Tue, Jun 15, 2021 at 10:06:08AM -0600, jim.cro...@gmail.com wrote:
> > > > > On Mon, Jun 14, 2021 at 1:20 AM Greg KH  wrote:
> > > > > >
> > > > > > On Mon, Jun 14, 2021 at 01:09:25AM -0600, jim.cro...@gmail.com 
> > > > > > wrote:
> > > > > > > serio_raw is apparently tainting the kernel when its modprobed.
> > > > > > > why ?  other modules load properly, no code changes to this module
> > > > > > >
> > > > > > > bash-5.1# dmesg | grep -i taint
> > > > > > > [6.517150] serio_raw: module verification failed: signature 
> > > > > > > and/or
> > > > > > > required key missing - tainting kernel
> > > > > >
> > > > > > You did not build this with the correct module signing key that your
> > > > > > kernel was built with.  That is what this warning is showing you, 
> > > > > > try
> > > > > > building all modules with the same key as your kernel had and you 
> > > > > > should
> > > > > > be fine.
> > > > > >
> > > > >
> > > > > OK, I understand better now -
> > > > >
> > > > > its nothing wrong with serio_raw, its just the 1st module to load,
> > > > > and warning comes just once.
> > > > > kernel/module.c
> > > > > 3962: pr_notice_once("%s: module verification failed: signature "
> > > > >
> > > > > Whats odd is that the same module has a signature when modinfo'd in
> > > > > the kernel running the laptop, but not from the same kernel running 
> > > > > inside a VM.
> > > > > Does this constitute a bug of some sort ?
> > > >
> > > > I do not understand, what is different here and what is not working
> > > > properly?
> > > >
> > >
> > > I have built and installed 5.13-rc6 onto my laptop, Im running it now.
> > > When I modinfo something, it shows a signature
> > >
> > > [jimc@frodo ~]$ modinfo pcspkr
> > > filename:
> > > /lib/modules/5.13.0-rc6-lm1-4-g28dc6f490a7f/kernel/drivers/input/misc/pcspkr.ko
> > > alias:  platform:pcspkr
> > > license:GPL
> > > description:PC Speaker beeper driver
> > > author: Vojtech Pavlik 
> > > depends:
> > > retpoline:  Y
> > > intree: Y
> > > name:   pcspkr
> > > vermagic:   5.13.0-rc6-lm1-4-g28dc6f490a7f SMP mod_unload
> > > sig_id: PKCS#7
> > > signer: Build time autogenerated kernel key
> > > sig_key:
> > > 73:9F:4D:24:D7:05:0A:55:AE:5C:B1:F6:52:B1:BA:E0:5C:68:32:36
> > > sig_hashalgo:   sha512
> > > signature:  
> > > 47:10:D7:A0:79:BE:B5:24:B1:BE:7F:53:8D:EF:4E:73:BD:39:5C:B4:
> > > CB:7A:CD:3F:C8:96:E4:7A:72:17:A0:2B:42:63:5A:0F:F6:8B:70:7E:
> > > ...
> > >
> > > when I run precisely the same kernel inside a virtme/kvm/qemu VM,
> > > the same modinfo lacks that sig stuff
> > > Note that vermagic matches exactly
> > >
> > > bash-5.1# modinfo pcspkr
> > > filename:
> > > /lib/modules/5.13.0-rc6-lm1-4-g28dc6f490a7f/kernel/drivers/input/misc/pcspkr.ko
> > > alias:  platform:pcspkr
> > > license:GPL
> > > description:PC Speaker beeper driver
> > > author: Vojtech Pavlik 
> > > depends:
> > > retpoline:  Y
> > > intree: Y
> > > name:   pcspkr
> > > vermagic:   5.13.0-rc6-lm1-4-g28dc6f490a7f SMP mod_unload
> > > bash-5.1#
> >
> >
> > Are you sure the modinfo you are running inside the vm knows to read the
> > signature information?  Odds are a busybox/toybox modinfo does not know
> > this type of thing.  Let me check:
> >
> > $ ./busybox modinfo visor | grep signature
> > $ modinfo visor | grep signature
> > signature:  51:F5:13:E1:F9:49:FA:20:68:45:F8:32:67:E2:4D:9C:DD:B6:55:EA:
> >
> > Yup, busybox does not know about these things.
> >
>
> that is interesting.   Its not the reason here, IIUC.
>
> Im using virtme for my VM,
> its big advantage is that it remounts the host system disks,
> so you get your whole home/host environment unchanged.
> Theres also no need to install a kernel to run it in the VM,
> I just happen to have installed the same kernel to run the whole laptop,
> (more to test my patches than to chase down this particular weirdness)
>


virtme-init: basic initialization done
virtme-init: running systemd-tmpfiles
Failed to create directory or subvolume "/var/spool/cups/tmp": Permission denied
Failed to open directory 'portables': Permission denied
Failed to open directory 'machines': Permission denied
Failed to open directory 'private': Permission denied
Failed to open directory 'private': Permission denied
systemd-tmpfile (184) used greatest stack depth: 26448 bytes left
virtme-init: starting udevd
Starting version v248.3-1.fc34

Im gonna handwave a key visibilty problem causing my wierdness

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: why does an in-tree loadable module taint the kernel

2021-06-16 Thread jim . cromie
On Wed, Jun 16, 2021 at 2:05 AM Greg KH  wrote:
>
> On Tue, Jun 15, 2021 at 12:26:19PM -0600, jim.cro...@gmail.com wrote:
> > On Tue, Jun 15, 2021 at 10:24 AM Greg KH  wrote:
> > >
> > > On Tue, Jun 15, 2021 at 10:06:08AM -0600, jim.cro...@gmail.com wrote:
> > > > On Mon, Jun 14, 2021 at 1:20 AM Greg KH  wrote:
> > > > >
> > > > > On Mon, Jun 14, 2021 at 01:09:25AM -0600, jim.cro...@gmail.com wrote:
> > > > > > serio_raw is apparently tainting the kernel when its modprobed.
> > > > > > why ?  other modules load properly, no code changes to this module
> > > > > >
> > > > > > bash-5.1# dmesg | grep -i taint
> > > > > > [6.517150] serio_raw: module verification failed: signature 
> > > > > > and/or
> > > > > > required key missing - tainting kernel
> > > > >
> > > > > You did not build this with the correct module signing key that your
> > > > > kernel was built with.  That is what this warning is showing you, try
> > > > > building all modules with the same key as your kernel had and you 
> > > > > should
> > > > > be fine.
> > > > >
> > > >
> > > > OK, I understand better now -
> > > >
> > > > its nothing wrong with serio_raw, its just the 1st module to load,
> > > > and warning comes just once.
> > > > kernel/module.c
> > > > 3962: pr_notice_once("%s: module verification failed: signature "
> > > >
> > > > Whats odd is that the same module has a signature when modinfo'd in
> > > > the kernel running the laptop, but not from the same kernel running 
> > > > inside a VM.
> > > > Does this constitute a bug of some sort ?
> > >
> > > I do not understand, what is different here and what is not working
> > > properly?
> > >
> >
> > I have built and installed 5.13-rc6 onto my laptop, Im running it now.
> > When I modinfo something, it shows a signature
> >
> > [jimc@frodo ~]$ modinfo pcspkr
> > filename:
> > /lib/modules/5.13.0-rc6-lm1-4-g28dc6f490a7f/kernel/drivers/input/misc/pcspkr.ko
> > alias:  platform:pcspkr
> > license:GPL
> > description:PC Speaker beeper driver
> > author: Vojtech Pavlik 
> > depends:
> > retpoline:  Y
> > intree: Y
> > name:   pcspkr
> > vermagic:   5.13.0-rc6-lm1-4-g28dc6f490a7f SMP mod_unload
> > sig_id: PKCS#7
> > signer: Build time autogenerated kernel key
> > sig_key:73:9F:4D:24:D7:05:0A:55:AE:5C:B1:F6:52:B1:BA:E0:5C:68:32:36
> > sig_hashalgo:   sha512
> > signature:  47:10:D7:A0:79:BE:B5:24:B1:BE:7F:53:8D:EF:4E:73:BD:39:5C:B4:
> > CB:7A:CD:3F:C8:96:E4:7A:72:17:A0:2B:42:63:5A:0F:F6:8B:70:7E:
> > ...
> >
> > when I run precisely the same kernel inside a virtme/kvm/qemu VM,
> > the same modinfo lacks that sig stuff
> > Note that vermagic matches exactly
> >
> > bash-5.1# modinfo pcspkr
> > filename:
> > /lib/modules/5.13.0-rc6-lm1-4-g28dc6f490a7f/kernel/drivers/input/misc/pcspkr.ko
> > alias:  platform:pcspkr
> > license:GPL
> > description:PC Speaker beeper driver
> > author: Vojtech Pavlik 
> > depends:
> > retpoline:  Y
> > intree: Y
> > name:   pcspkr
> > vermagic:   5.13.0-rc6-lm1-4-g28dc6f490a7f SMP mod_unload
> > bash-5.1#
>
>
> Are you sure the modinfo you are running inside the vm knows to read the
> signature information?  Odds are a busybox/toybox modinfo does not know
> this type of thing.  Let me check:
>
> $ ./busybox modinfo visor | grep signature
> $ modinfo visor | grep signature
> signature:  51:F5:13:E1:F9:49:FA:20:68:45:F8:32:67:E2:4D:9C:DD:B6:55:EA:
>
> Yup, busybox does not know about these things.
>

that is interesting.   Its not the reason here, IIUC.

Im using virtme for my VM,
its big advantage is that it remounts the host system disks,
so you get your whole home/host environment unchanged.
Theres also no need to install a kernel to run it in the VM,
I just happen to have installed the same kernel to run the whole laptop,
(more to test my patches than to chase down this particular weirdness)


> Is the md5sum the same for these modules?

Yes.  module is same, so is cksum /sbin/modinfo



> > > If you rebuild modules for a kernel without having the key, yes, you
> > > will get this warning.  You have to have the same key here.
> >
> > heres how Ive configured:
> > - copy distro .config from /boot  (Fedora)
> > - make localmodconfig (to drop building parts I wont need)
> > - virtme-configkernel --update  (to get support for 9P, virtio etc to
> > mount host disks)
> >
> > all the SECURITY stuff came from the distro config,
> > I havent yet tried to unconfigure it.
> >
> > I havent done anything specific with keys, I dont know why whatever
> > key is involved
> > is not available for both scenarios.
> > here's the relevant (I hope) config items:
>
> Look at the CONFIG_MODULE_SIG* items, that's the relevant ones.
>
> Here's what I use in my custom kernels for my systems:
>
> $ zcat /proc/config.gz | grep MODULE_SIG
> CONFIG_MODULE_SIG_FORMAT=y
> CONFIG_MODULE_SIG=y
> CONFIG_MODULE_SIG_FORCE=y
> 

Re: why does an in-tree loadable module taint the kernel

2021-06-15 Thread jim . cromie
On Tue, Jun 15, 2021 at 10:24 AM Greg KH  wrote:
>
> On Tue, Jun 15, 2021 at 10:06:08AM -0600, jim.cro...@gmail.com wrote:
> > On Mon, Jun 14, 2021 at 1:20 AM Greg KH  wrote:
> > >
> > > On Mon, Jun 14, 2021 at 01:09:25AM -0600, jim.cro...@gmail.com wrote:
> > > > serio_raw is apparently tainting the kernel when its modprobed.
> > > > why ?  other modules load properly, no code changes to this module
> > > >
> > > > bash-5.1# dmesg | grep -i taint
> > > > [6.517150] serio_raw: module verification failed: signature and/or
> > > > required key missing - tainting kernel
> > >
> > > You did not build this with the correct module signing key that your
> > > kernel was built with.  That is what this warning is showing you, try
> > > building all modules with the same key as your kernel had and you should
> > > be fine.
> > >
> >
> > OK, I understand better now -
> >
> > its nothing wrong with serio_raw, its just the 1st module to load,
> > and warning comes just once.
> > kernel/module.c
> > 3962: pr_notice_once("%s: module verification failed: signature "
> >
> > Whats odd is that the same module has a signature when modinfo'd in
> > the kernel running the laptop, but not from the same kernel running inside 
> > a VM.
> > Does this constitute a bug of some sort ?
>
> I do not understand, what is different here and what is not working
> properly?
>

I have built and installed 5.13-rc6 onto my laptop, Im running it now.
When I modinfo something, it shows a signature

[jimc@frodo ~]$ modinfo pcspkr
filename:
/lib/modules/5.13.0-rc6-lm1-4-g28dc6f490a7f/kernel/drivers/input/misc/pcspkr.ko
alias:  platform:pcspkr
license:GPL
description:PC Speaker beeper driver
author: Vojtech Pavlik 
depends:
retpoline:  Y
intree: Y
name:   pcspkr
vermagic:   5.13.0-rc6-lm1-4-g28dc6f490a7f SMP mod_unload
sig_id: PKCS#7
signer: Build time autogenerated kernel key
sig_key:73:9F:4D:24:D7:05:0A:55:AE:5C:B1:F6:52:B1:BA:E0:5C:68:32:36
sig_hashalgo:   sha512
signature:  47:10:D7:A0:79:BE:B5:24:B1:BE:7F:53:8D:EF:4E:73:BD:39:5C:B4:
CB:7A:CD:3F:C8:96:E4:7A:72:17:A0:2B:42:63:5A:0F:F6:8B:70:7E:
...

when I run precisely the same kernel inside a virtme/kvm/qemu VM,
the same modinfo lacks that sig stuff
Note that vermagic matches exactly

bash-5.1# modinfo pcspkr
filename:
/lib/modules/5.13.0-rc6-lm1-4-g28dc6f490a7f/kernel/drivers/input/misc/pcspkr.ko
alias:  platform:pcspkr
license:GPL
description:PC Speaker beeper driver
author: Vojtech Pavlik 
depends:
retpoline:  Y
intree: Y
name:   pcspkr
vermagic:   5.13.0-rc6-lm1-4-g28dc6f490a7f SMP mod_unload
bash-5.1#


> If you rebuild modules for a kernel without having the key, yes, you
> will get this warning.  You have to have the same key here.

heres how Ive configured:
- copy distro .config from /boot  (Fedora)
- make localmodconfig (to drop building parts I wont need)
- virtme-configkernel --update  (to get support for 9P, virtio etc to
mount host disks)

all the SECURITY stuff came from the distro config,
I havent yet tried to unconfigure it.

I havent done anything specific with keys, I dont know why whatever
key is involved
is not available for both scenarios.
here's the relevant (I hope) config items:

[jimc@frodo local-i915m]$ grep SALT .config
CONFIG_BUILD_SALT="5.8.12-200.fc32.x86_64"

[jimc@frodo local-i915m]$ grep _KEY .config | grep -v '#'
CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS=y
CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS=y
CONFIG_INPUT_KEYBOARD=y
CONFIG_KEYBOARD_ATKBD=y
CONFIG_KEYS=y
CONFIG_KEYS_REQUEST_CACHE=y
CONFIG_PERSISTENT_KEYRINGS=y
CONFIG_ENCRYPTED_KEYS=y
CONFIG_KEY_DH_OPERATIONS=y
CONFIG_KEY_NOTIFICATIONS=y
CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y
CONFIG_INTEGRITY_TRUSTED_KEYRING=y
CONFIG_INTEGRITY_PLATFORM_KEYRING=y
CONFIG_LOAD_UEFI_KEYS=y
CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY=y
CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS=y
CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS=y
CONFIG_ASYMMETRIC_KEY_TYPE=y
CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"
CONFIG_SYSTEM_TRUSTED_KEYRING=y
CONFIG_SYSTEM_TRUSTED_KEYS=""
CONFIG_SECONDARY_TRUSTED_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_KEYRING=y
[jimc@frodo local-i915m]$

[jimc@frodo local-i915m]$ grep SECURITY .config | grep -v '#'
CONFIG_IP_NF_SECURITY=m
CONFIG_IP6_NF_SECURITY=m
CONFIG_EXT4_FS_SECURITY=y
CONFIG_SECURITY=y
CONFIG_SECURITY_WRITABLE_HOOKS=y
CONFIG_SECURITYFS=y
CONFIG_SECURITY_NETWORK=y
CONFIG_SECURITY_NETWORK_XFRM=y
CONFIG_SECURITY_SELINUX=y
CONFIG_SECURITY_SELINUX_BOOTPARAM=y
CONFIG_SECURITY_SELINUX_DISABLE=y
CONFIG_SECURITY_SELINUX_DEVELOP=y
CONFIG_SECURITY_SELINUX_AVC_STATS=y
CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=0
CONFIG_SECURITY_SELINUX_SIDTAB_HASH_BITS=9
CONFIG_SECURITY_SELINUX_SID2STR_CACHE_SIZE=256
CONFIG_SECURITY_YAMA=y
CONFIG_SECURITY_LOCKDOWN_LSM=y
CONFIG_SECURITY_LOCKDOWN_LSM_EARLY=y
CONFIG_DEFAULT_SECURITY_SELINUX=y


Re: why does an in-tree loadable module taint the kernel

2021-06-15 Thread jim . cromie
On Mon, Jun 14, 2021 at 1:20 AM Greg KH  wrote:
>
> On Mon, Jun 14, 2021 at 01:09:25AM -0600, jim.cro...@gmail.com wrote:
> > serio_raw is apparently tainting the kernel when its modprobed.
> > why ?  other modules load properly, no code changes to this module
> >
> > bash-5.1# dmesg | grep -i taint
> > [6.517150] serio_raw: module verification failed: signature and/or
> > required key missing - tainting kernel
>
> You did not build this with the correct module signing key that your
> kernel was built with.  That is what this warning is showing you, try
> building all modules with the same key as your kernel had and you should
> be fine.
>

OK, I understand better now -

its nothing wrong with serio_raw, its just the 1st module to load,
and warning comes just once.
kernel/module.c
3962: pr_notice_once("%s: module verification failed: signature "

Whats odd is that the same module has a signature when modinfo'd in
the kernel running the laptop, but not from the same kernel running inside a VM.
Does this constitute a bug of some sort ?
A pretty small one, likely fixable by changing CONFIG_SECURITY etc.

For anyone else needing to decode a taint:
https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html


> thanks,
>
> greg k-h

thank you

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


why does an in-tree loadable module taint the kernel

2021-06-14 Thread jim . cromie
serio_raw is apparently tainting the kernel when its modprobed.
why ?  other modules load properly, no code changes to this module

bash-5.1# dmesg | grep -i taint
[6.517150] serio_raw: module verification failed: signature and/or
required key missing - tainting kernel
[7.449072] CPU: 0 PID: 203 Comm: systemd-udevd Tainted: G
  E 5.13.0-rc6-lm1-4-g28dc6f490a7f #106

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


how to return unneeded init-data to kernel ?

2021-06-03 Thread jim . cromie
hi all,

When one builds with CONFIG_DYNAMIC_DEBUG=y
one consumes extra memory for kernel data

Ive managed to coax dyndbg into "not needing" about 30KiB in a
__dyndbg* section,
how can I return it to the kernel ?

https://lore.kernel.org/lkml/20210529200029.205306-1-jim.cro...@gmail.com/

b4:
dyndbg: 284 modules, 3013 entries and 11360 bytes in ddebug tables,
168728 bytes in __dyndbg section
after:
dyndbg: 2900 prdebugs in 277 modules, 12 KiB in ddebug tables, 90 KiB
in __dyndbg section, 67 KiB in __dyndbg_sites section

about 30Kib of the 67 is recoverable


patchset, the short version:

A- split __dyndbg in 2, isolate repeating module,file,function data.
reach by new .site ptr.
B- be safe if !.site
C- work towards replacing .site with indexing on vectors: __dyndbgs &
__dyndbg_sites
c1 add ._index
c2 use .index to get to __dyndbgs[0]  ( then -> sites[._index] )
c3 insert header record at __dyndbgs[0]
c4 rework header to differentiate from struct _ddebug, keep .site
c5 drop .site, use indirection to get sites[._index]
D- split _index into 2 jobs; _back (to [0]) and _map (to [N])
E- find duplicate site recs
e1 - use just 1st of duplicate blocks
e2 - in modules, move new site recs into front of sites vector
e3 - in builtins, pack the whole sites vector, not just within the module-blocks

So that leaves about 40% of __dyndbg_sites unneeded.

How to return this to free memory ?

FWIW, I tried krealloc on a module's chunk of memory
(as attached by module:load_info())
it might have worked if that chunk was kallocd separately
by elf-loader code.  It evidently was not.

PS: questions welcome here, reviews probably best at lkml

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to test device driver?

2021-05-17 Thread jim . cromie
On Mon, May 17, 2021 at 5:54 PM Hyeonggon Yoo <42.hye...@gmail.com> wrote:
>
> On Mon, May 17, 2021 at 12:48:38PM -0600, jim.cro...@gmail.com wrote:
> > On Mon, May 17, 2021 at 9:28 AM Hyeonggon Yoo <42.hye...@gmail.com> wrote:
> > >
> > > Hello, there are lots of drivers in linux.
> > >
> > > My questions are:
> > >
> > >   - how can we test driver? is it just using that device for a long
> > > time as a user?
> > >
> > testing is hard.  Having the device is highly recommended.
> > ISTM essential if adding a Tested-by: tag
> > Do you have a particular device in mind ?
>
> I recently was tracking syzbot report that is occured in
> sound driver. I don't have the device, but was curious about
> what the test method is.

well, it surely depends on the bug - and whether its reproducible.

if you could defend the patch as "obviously correct"
you could reasonably send it without extensive testing,
case by case Id guess.

>
> > You could reply to that report email, with your patch included.
> > 0day/lkp robot watches many email lists, and might test your patch
> > automatically, for you on different architectures
> >
> > at least Ive seen it happening on kbuild, kbuild-all lists
>
> well, build tests are useful but it is not enough, we should run the
> code on actual device. is it possible to make the bot test the device
> (which I don't have) even if there is no syzbot reproducer?
>

its possible / practical to disqualify patches robotically,
but to bless them takes a priest.
Robots win by prequalifying submissions.

> I think I need to learn about bots more..
>

Now think about how its a real-life turing test.

0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
___
kbuild-all mailing list -- kbuild-...@lists.01.org
To unsubscribe send an email to kbuild-all-le...@lists.01.org

theres also a wiki, which helped me make sense of things
a bit better than the torrent of reports

> Thanks,
> Hyeongogn Yoo
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to test device driver?

2021-05-17 Thread jim . cromie
On Mon, May 17, 2021 at 9:28 AM Hyeonggon Yoo <42.hye...@gmail.com> wrote:
>
> Hello, there are lots of drivers in linux.
>
> My questions are:
>
>   - how can we test driver? is it just using that device for a long
> time as a user?
>
testing is hard.  Having the device is highly recommended.
ISTM essential if adding a Tested-by: tag
Do you have a particular device in mind ?


>   - what to do if there's a bug (like syzbot report), fixed it,
> but if we don't have that device?
>

You could reply to that report email, with your patch included.
0day/lkp robot watches many email lists, and might test your patch
automatically, for you on different architectures

at least Ive seen it happening on kbuild, kbuild-all lists


> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


kernel module parameter API ala drm.debug

2021-05-10 Thread jim . cromie
so as a proof of concept, Ive converted drm to use dynamic-debug

drm has ~dozen categories of debug messages, mapped to bits
in drm.debug, aka /sys/module/drm/parameters/debug
these bits are checked at runtime by drm_debug_enabled()
to do drm debug printing.

my patchset updates users of drm_debug_enabled()
to call pr_debug instead, avoiding lots of bit-checking.

it maps bits of drm.debug using dynamic_debug_exec_queries(),
a recently exported function to support this sort of thing.

you can see it here
https://github.com/jimc/linux/tree/dd-drm

A narrower interface than dynamic_debug_exec_queries() is possible:

+static char *format_prefix_classes[] = {
+   "gvt: cmd: ",
+   "gvt: core: ",
+   "gvt: dpy: ",
+   "gvt: el: ",
+   "gvt: irq: ",
+   "gvt: mm: ",
+   "gvt: mmio: ",
+   "gvt: render: ",
+   "gvt: sched: "
+};

+static const struct kernel_param_ops param_ops_dyndbg = {
+   .set = param_set_dyndbg,
+   .get = param_get_dyndbg,
+};
+
+#define info_ln(hexi, prefix) "\n\t0x" __stringify(hexi) "\t" prefix
+
+MODULE_PARM_DESC(debug_gvt, " gvt debug categories:"
+info_ln(1, "gvt: cmd:")
+info_ln(2, "gvt: core:")
+info_ln(4, "gvt: dpy:")
+info_ln(8, "gvt: el:")
+info_ln(10, "gvt: irq:")
+info_ln(20, "gvt: mm:")
+info_ln(40, "gvt: mmio:")
+info_ln(80, "gvt: render:")
+info_ln(100, "gvt: sched:"));
+
+module_param_cb(debug_gvt, _ops_dyndbg, &__gvt_debug, 0644);

this is useful in that it shows up  in modinfo output
but there could be better presentation,
maybe /sys/module/drm/parameters/debug.help

param_set_dyndbg could be moved into dynamic-debug proper,
instead of reimplemented everywhere debug bits control debug prints
(currently drm, maybe others, could be i915/gvt)

the point is that this integer parameter maps consecutive bits to "classes"
named in an input vector.  these "classes" are  just format ^prefix queries
clearly we shouldnt need the 1,2,4...

whats a good interface design for this module-param-bitmap ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Does FreeRTOS works on Linux?

2021-05-10 Thread jim . cromie
On Sun, May 9, 2021 at 12:41 AM loïc tourlonias
 wrote:
>
> > if using a posix thread full fills the requirement of RTOS. The reason
> > I want to use RTOS is , I am porting a Microcontroller code using RTOS
> > (free RTOS) to Linux and
> > afaik FreeRTOS doesnt work on Linux.
> > > FreeRTOS is a standalone OS and depending on your system there may be
> > > an example running on your architecture in parallel of your embedded
> > > Linux. For example, on one of my project with have an ARM Cortex-A7
> > > with Linux running in Normal World and FreeRTOS running in Trusted
> > > world.
> > This is interesting , do you have something to share?
> Sorry, this is intellectual property from my company so I can't share
> source code but we have started from the FreeRTOS porting sample
> related to our architecture. We are working on a ARM Cortex-A7 which
> have an isolation between a normal world and a secure world. Linux is
> working on the normal world for the UI and FreeRTOS is running on the
> secure world. Communication between the two worlds is made by SMC.
>
> Regards
> Loïc
>

You should look at Xenomai

it uses the Adeos interrupt pipeline to pick off and handle certain
interrupts and events
in real-time, and pass the rest off to the linux kernel that does all
setup and housekeeping

they have API interfaces for VXworks, and other commercial RTOSs
one of those APIs is probably your path of least portage.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Test if a socket accept is from external network

2021-05-04 Thread jim . cromie
On Sun, Apr 25, 2021 at 6:02 AM Jeffrey Walton  wrote:
>
> On Sun, Apr 25, 2021 at 7:09 AM John Wood  wrote:
> >
> > I'm working in a LSM to detect and mitigate fork brute force attacks
> > against vulnerable userspace applications. Now, to fine tuning the
> > detection I want to detect a network activity.  ...
> > How can I detect that an external connection (using a net device) is
> > accepted and avoid internal network communication?
>
> One caveat that may (or may not) apply...
>
> Systemd opens sockets for services even when a service is disabled. It
> could appear that a system is accepting traffic even when the service
> is unavailable.
>
> Jeff
>

this is interesting, it lets systemd add a tarpit to stall those SYN
connections.
But maybe bpf will do this soon.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Device driver .shutdown() VS .remove()

2021-04-22 Thread jim . cromie
On Thu, Apr 22, 2021 at 1:37 AM Luca Ceresoli  wrote:

> Hello,
>
> despite having been searching for documentation I couldn't find out the
> exact and detailed difference between the .shutdown() and .remove()
> calls in struct device_driver.
>
>
so, I'll start by saying I know next to nothing, but most of what you said
sounds good




> From the above it looks like the shutdown() actions must be a subset of
> remove() actions.
>
>
but subset is a bit vague.
theres 2 dimensions to think about.
lifetime -  shutdown/startup is surely the longer window, add/remove happen
within that
hierarchy - subsystems must be ready to handle add / remove

fwiw, I 'grepped' (with ack), it shows a few drivers with both functions,
many others with just remove
you could see in detail what the difference is.

$> ack '(\.remove|\.shutdown)\b' drivers/

drivers/rtc/rtc-twl.c
645: .remove = twl_rtc_remove,
646: .shutdown = twl_rtc_shutdown,

>
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Unable to boot to kernel built from stable 5.11.y

2021-04-02 Thread jim . cromie
On Tue, Mar 30, 2021 at 7:16 AM Andrew Adamson 
wrote:

> Hi Everyone,
>
> I tried to build the kernel myself for the first a few days ago. While the
> build was successful, I am unable to boot to it. After grub I get a
> blinking cursor for 15 to 30 minutes, and then a message that says "Please
> reboot and select proper boot device."
>
>
I dont know your higher mission, but I'll suggest:

punt on grub install at least temporarily,
Try virtme.
its a super-easy way to run your built kernel on a VM
the VM is setup to use your existing installation
so theres no extra configuration to fuss with.

[jimc@frodo t2]$ virtme-
virtme-configkernelvirtme-mkinitramfs virtme-prep-kdir-mods
 virtme-run


this is probably all you need to enable the right features in your built
kernel,
basically VIRTIO + NET

[jimc@frodo t2]$ virtme-configkernel --update
  GEN Makefile
.config:3468:warning: override: reassigning to symbol UEVENT_HELPER
.config:3469:warning: override: reassigning to symbol VIRTIO
.config:3472:warning: override: reassigning to symbol NET
.config:3482:warning: override: reassigning to symbol BINFMT_SCRIPT
.config:3486:warning: override: reassigning to symbol MODULE_SIG_FORCE
.config:3487:warning: override: reassigning to symbol DEVTMPFS
.config:3488:warning: override: reassigning to symbol TTY
.config:3492:warning: override: reassigning to symbol INOTIFY_USER
.config:3495:warning: override: reassigning to symbol BLOCK
.config:3505:warning: override: reassigning to symbol WATCHDOG
.config:3506:warning: override: reassigning to symbol WATCHDOG_CORE
.config:3509:warning: override: reassigning to symbol SERIO
.config:3511:warning: override: reassigning to symbol INPUT
.config:3518:warning: override: reassigning to symbol FB
.config:3521:warning: override: reassigning to symbol RTC_CLASS
.config:3525:warning: override: reassigning to symbol PARAVIRT
#
# configuration written to .config
#
Configured.  Build with 'make ARCH=x86 -j8'
[jimc@frodo t2]$

there are options to let you mount directories, to keep your VMs work,
so this might satisfy your itch.

then, you can decide whether you need to mess with grub,
and if you do, youll have some own-kernel experience to help.



>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


patchset grooming question.

2021-03-25 Thread jim . cromie
I have a patchset which touches  vmlinux.lds.h 2x

1st inserts a few lines,
2nd moves them and related to a separate macro.

this is sub-optimal, if new macro is warranted,
it should just do that in 1st change.

or maybe 3rd option.
  move existing to macro- no functional change
  then do 2 changes, separately.

Whats best approach, considering history and blamelog ?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: make menuconfig

2021-03-25 Thread jim . cromie
On Sat, Mar 20, 2021 at 1:07 PM Martin Herdeis  wrote:

> Hello,
>
> I am trying to learn more about the kernel build system and due to that I
> tried the following in the top level Kconfig file right at the beginning:
>
> config FOO
> tristate
> prompt "FOO"
> config BAR
> tristate "BAR" if FOO
>


i suspect that last line - it feels like a thinko,
combining a declaration  and a dependency.

moreover,   `ack tristate`   (recursive grep w other nicetohaves)
shows 0 such uses.

heres typical usage

drivers/infiniband/hw/hfi1/Kconfig
3: tristate "Intel OPA Gen1 support"

drivers/infiniband/hw/vmw_pvrdma/Kconfig
3: tristate "VMware Paravirtualized RDMA Driver"

drivers/infiniband/hw/mlx4/Kconfig
3: tristate "Mellanox ConnectX HCA support"

drivers/infiniband/hw/mthca/Kconfig
3: tristate "Mellanox HCA support"

drivers/infiniband/hw/qib/Kconfig
3: tristate "Intel PCIe HCA support"




> default y
>
> Then I do a make menuconfig and choose the config option FOO with "m" then
> the config option BAR shows up with "y". if I exit and save this
> constellation m/y shows up in the .config file. But as I understand the
> logic the value of the config option FOO defines the upper level for the
> value of the config option BAR.
>
> When I do just a make menuconfig again both options show up as m even
> though in the .config file they are still saved as y/m.
>
> Is that a problem with the default value of BAR? Am I not supposed to give
> it a default value out of range when FOO is m?
>
>
> Thank you,
>
> Martin
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to switch between installed kernel and developed kernel

2021-03-25 Thread jim . cromie
>
>
>
> I've found running a kernel under qemu with my normal rootfs to be quite
> useful to quickly try out things. See the qemu-test script in the RAUC
> project
> for an example: https://github.com/rauc/rauc/blob/master/qemu-test
>
>

I would agree.
I find "virtme" tool to be super simple and effective.
It reuses your running system install, mounted with 9P,
no need to futz with a 2nd system image.
I barely had to tinker with all the qemu options and args...

heres my every-day usage (w my own boring shell funcs wrapping)
function krun () {
echo vm$KRUN_SHOW $KRUN_STDS $KDBG_OPTS $QM_OPTS $*
virtme-run $KRUN_SHOW $KRUN_STDS $KDBG_OPTS $QM_OPTS $*
# -qmp tcp:localhost:,server,nowait
}
[jimc@frodo local-i915m]$ krun
vm --show-command --show-boot-console --kdir . --mods=auto --kopt nokaslr
--kopt dynamic_debug.verbose=3 --kopt module.dyndbg=+pmf --qemu-opts
-machine dump-guest-core=on -m 2G
./.virtme_mods/lib/modules/0.0.0
/usr/bin/qemu-system-x86_64 -fsdev
local,id=virtfs1,path=/,security_model=none,readonly,multidevs=remap
-device virtio-9p-pci,fsdev=virtfs1,mount_tag=/dev/root -fsdev
local,id=virtfs5,path=/usr/local/lib/python3.9/site-packages/virtme-0.1.1-py3.9.egg/virtme/guest,security_model=none,readonly,multidevs=remap
-device virtio-9p-pci,fsdev=virtfs5,mount_tag=virtme.guesttools -machine
accel=kvm:tcg -watchdog i6300esb -cpu host -parallel none -net none -echr 1
-serial none -chardev stdio,id=console,signal=off,mux=on -serial
chardev:console -mon chardev=console -vga none -display none -kernel
./arch/x86/boot/bzImage -append
'virtme_link_mods=/home/jimc/projects/lx/wk-next/builds/local-i915m/.virtme_mods/lib/modules/0.0.0
earlyprintk=serial,ttyS0,115200 console=ttyS0 psmouse.proto=exps
"virtme_stty_con=rows 24 cols 141 iutf8" TERM=xterm-256color rootfstype=9p
rootflags=version=9p2000.L,trans=virtio,access=any raid=noautodetect ro
nokaslr dynamic_debug.verbose=3 module.dyndbg=+pmf init=/bin/sh -- -c
"mount -t tmpfs run /run;mkdir -p /run/virtme/guesttools;/bin/mount -n -t
9p -o ro,version=9p2000.L,trans=virtio,access=any virtme.guesttools
/run/virtme/guesttools;exec /run/virtme/guesttools/virtme-init"' -machine
dump-guest-core=on -m 2G
Wrong EFI loader signature.
early console in extract_kernel
input_data: 0x047a340d
input_len: 0x009f7f00
output: 0x0100
output_len: 0x04139814
kernel_total_size: 0x0363
needed_size: 0x0420
trampoline_32bit: 0x0009d000


KASLR disabled: 'nokaslr' on cmdline.

..
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: pid start time and new display field in proc pid stat

2021-03-25 Thread jim . cromie
On Thu, Mar 25, 2021 at 6:53 AM Navin P  wrote:

> Hi,
>
>  As of 5.11 kernel (pid,pid_start_time) is not unique /monotonic even
> though the underlying counters are .
>  I chose start_boottime because i wanted the counter to increase
> during suspend as well.
>
> 1. Is there any case where task->start_boottime or
> ktime_get_boottime_ns doesn't become monotonic i.e increasing ?
>
> 2.  If start_boottime is not monotonic which counter to use ?
>
> 3.  If i create a new field in task_struct , then i can use a
> atomic_add_return(1,) to fill in the task->new_field. Will this also
> work ?
>
>
Its my understanding that task-struct is a highly "contended" resource.

its a basic element, its size matters
everybody wants a bit/byte for something special,
conflicts ensue (or could).
nobody gets them without a real good reason.

I dont know what youre trying to achieve, but i suspect that
youll need to find a more subtle way of doing it.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


"module:find_symbol: Failed to find symbol ....." not so bad.

2021-03-25 Thread jim . cromie
so when I enable the pr_debug()s in kernel/module,
and boot that kernel, I get a raft of messages (~800),
like :


[  110.072535] module:find_symbol: Failed to find symbol
drm_scdc_get_scrambling_status
[  110.072538] module:find_symbol: Failed to find symbol drm_scdc_read
[  110.072541] module:find_symbol: Failed to find symbol
drm_scdc_set_high_tmds_clock_ratio
[  110.072545] module:find_symbol: Failed to find symbol
drm_scdc_set_scrambling
[  110.072548] module:find_symbol: Failed to find symbol drm_scdc_write
[  110.072551] module:find_symbol: Failed to find symbol
drm_self_refresh_helper_alter_state
[  110.072553] module:find_symbol: Failed to find symbol
drm_self_refresh_helper_cleanup


What is the potential importance of these ?
clearly if it were a real problem, it wouldnt just be a debug message.
Is there anything to fix here, either in local config, or in code ?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: are 1-wire devices "discoverable"?

2021-03-18 Thread jim . cromie
On Sat, Feb 13, 2021 at 11:58 AM Trevor Woerner  wrote:

> Hi,
>

> It's true that you do need a device tree overlay to tell the kernel that
> you
> want to use the 1-wire bus, and you have to tell the kernel which GPIO pin
> you
> want to use as the 1 wire, but after that, attaching DS18B20 devices to a
> running system works quite magically.[4]
>
> Each DS18B20 has a unique 64-bit number burned into it, the first 8 bits
> specify the device type (i.e. the DS18B20), the next 48 bits are a unique
> serial number, and the last 8 bits are a CRC of the previous 56 bits. Due
> to
> the inclusion of the 8-bit device type, when I plug a DS18B20 into my
> board,
> the kernel automatically creates a sysfs entry for it with a "temperature"
> file that I can read to obtain the temperature in Celcius.
>
>
so, this device looks discoverable on a bus,
once you know the bus is there.
thats the 1st distinction to make.
there are degrees/features.
Id also ask:
is that ID at a standard location ?
via some base transaction that all devices support ?

in my own house, I can find a switch in the dark.
I dont have Alexa listening to render help.





> I don't know if that qualifies as "discoverable"? It's certainly a lot more
> discoverable than I2C or SPI, although maybe not quite as discoverable as,
> say, PCI. Specifying the 1 wire is not discoverable, but plugging 1-wire
> devices into my board is maybe something that could be described as
> discoverable?
>
> Best regards,
> Trevor
>
> [1] https://www.youtube.com/watch?v=a9CZ1Uk3OYQ
> [2]
> https://twoerner.blogspot.com/2020/12/temperature-readings-with-ds18b20-and.html
> [3]
> https://twoerner.blogspot.com/2021/01/sensing-temperature-with-raspberrypi.html
> [4]
> https://twoerner.blogspot.com/2020/12/multiple-ds18b20-temperature-probes.html
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: is there an efficient module_is_builtin() test ?

2021-03-16 Thread jim . cromie
On Tue, Mar 9, 2021 at 3:25 PM Valdis Klētnieks 
wrote:

> On Tue, 09 Mar 2021 12:55:14 -0700, jim.cro...@gmail.com said:
>
> > To use the index, I need  _sites[], and that only works
> > for builtin-module's callsites.   For loaded modules, I can/have
> > added a pointer to the section into module load_info, giving me
> > the base I will need for the ! builtin branch.
> >
> > I just need a not expensive  is-it-builtin (modref)
>

thanks Valdis, the back and forth helped.

So, to follow up, the above is embodied here;
https://lore.kernel.org/lkml/20210316050801.2446401-1-jim.cro...@gmail.com/
in the add index patch, near 13/18
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


help with linker script mods

2021-03-16 Thread jim . cromie
so Im trying to constrain the linker to put ELF section pairs
into contiguous chunks of memory.

this is on top of:
https://lore.kernel.org/lkml/20210316050801.2446401-1-jim.cro...@gmail.com/

The macro below works when used in vmlinux.lds.h,
it does pack the sections as desired.

but same macro, when reused in module.lds.h, fails.

The version below links ok, but appears to absorb the __dyndbg* sections
into the .data section, which works for vmlinux.lds.h, cuz there we use the
__start/stop ___dyndbg* symbols to use the section.

In contrast, for modules, I want to preserve the named sections
as proper elf sections in the ko, so that loader picks them up
and saves them into struct load-info

Anyone got some deep linker-fu ?


[jimc@frodo wk-next]$ git diff
diff --git a/include/asm-generic/module.lds.h
b/include/asm-generic/module.lds.h
index f210d5c1b78b..4840f01a0828 100644
--- a/include/asm-generic/module.lds.h
+++ b/include/asm-generic/module.lds.h
@@ -4,7 +4,26 @@

 /*
  *  can specify arch-specific sections for linking
modules.
- * Empty for the asm-generic header.
+ * DYNAMIC_DEBUG needs its header sections contiguous with its data
sections.
  */

+#if defined(CONFIG_DYNAMIC_DEBUG) ||\
+(defined(CONFIG_DYNAMIC_DEBUG_CORE) \
+ && defined(DYNAMIC_DEBUG_MODULE))
+#define DYNAMIC_DEBUG_DATA()\
+. = ALIGN(8);   \
+__start___dyndbg_sites = .; \
+KEEP(*(__dyndbg_sites .gnu.linkonce.dyndbg_site))   \
+__stop___dyndbg_sites = .;  \
+__start___dyndbg = .;   \
+KEEP(*(__dyndbg .gnu.linkonce.dyndbg))  \
+__stop___dyndbg = .;
+#else
+#define DYNAMIC_DEBUG_DATA()
+#endif
+
+SECTIONS {
+   .data : { DYNAMIC_DEBUG_DATA() }
+}
+
 #endif /* __ASM_GENERIC_MODULE_LDS_H */
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


is there an efficient module_is_builtin() test ?

2021-03-09 Thread jim . cromie
Im trying to reduce memory used by
internal tables built into DYNAMIC_DEBUG

the main savings available is in the per pr_debug*
callsite data: modname, filename, funcname.

I have segregated those fields to a new __dyndbg_sites section,
described by struct _ddebug_site, and now refd by new ptr in
struct _ddebug

That new ptr enlarges the memory footprint, so I want to replace it
with an integer index into the section / array.  Existing padding could
hold the index.

To use the index, I need  _sites[], and that only works
for builtin-module's callsites.   For loaded modules, I can/have
added a pointer to the section into module load_info, giving me
the base I will need for the ! builtin branch.

I just need a not expensive  is-it-builtin (modref)
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Does 'make oldconfig' work across different architectures?

2021-02-18 Thread jim . cromie
On Thu, Feb 18, 2021 at 8:07 PM  wrote:

> Hello folks,
>
> When we want to use an old .config file for a new kernel build, we can use
> (place in build location) that .config and do ‘make oldconfig’ so that the
> build system lets us to fill the new config variables.
>
> I'm curious if this 'make oldconfig' will work if the old .config is from
> different architecture (like sparc) and I have to configure it for aarch64.
>
> The old .config file is a minimal configuration with timer, interrupt
> controller and uart for minimal linux booting.
>
> Thanks!
>
Chan Kim
> __


you need to define "working".

I bet it would work to produce a config that is syntactically correct.
whether it builds a bootable kernel is less clear.

Ive only built and installed to hw 1 non-x86 kernel,
so my experience isnt relevant to other arches, ymmv

ISTM
you should try defconfig for aarch64
your .config, updated with oldconfig
diff them, see whats happened to various CONFIG vars
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: '-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ?

2021-01-29 Thread jim . cromie
... and somethings not right.  debugger KBUILD_SYM shows it:
these records are same as those shown in early boot output pasted previously

these records look right

(gdb) p *__start___dyndbg_sites@10
$2 = {{modname = 0x825a8ab9 "head64",
filename = 0x825a8ac0 "include/linux/dynamic_debug.h",
function = 0x825a8ab9 "head64"}, {modname = 0x825a8ade
"ebda",
filename = 0x825a8ac0 "include/linux/dynamic_debug.h", function
= 0x825a8ade "ebda"}, {
modname = 0x825a8ae3 "platform_quirks",
filename = 0x825a8ac0 "include/linux/dynamic_debug.h",
function = 0x825a8ae3 "platform_quirks"}, {modname =
0x825cac42 "main",
filename = 0x825a8afe "init/main.c",
function = 0x822000e0 <__func__.2> "run_init_process"},
{modname = 0x825cac42 "main",
filename = 0x825a8afe "init/main.c",
function = 0x822000e0 <__func__.2> "run_init_process"},
{modname = 0x825cac42 "main",
filename = 0x825a8afe "init/main.c",
function = 0x822000e0 <__func__.2> "run_init_process"},
{modname = 0x825cac42 "main",
filename = 0x825a8afe "init/main.c",
function = 0x822000e0 <__func__.2> "run_init_process"},
{modname = 0x825cac42 "main",
filename = 0x825a8afe "init/main.c",
function = 0x822000a0 <__func__.0> "initcall_blacklisted"}, {
modname = 0x825cac42 "main", filename = 0x825a8afe
"init/main.c",
function = 0x822000c0 <__func__.1> "initcall_blacklist"}, {
modname = 0x825cac42 "main", filename = 0x825a8ac0
"include/linux/dynamic_debug.h",
function = 0x825cac42 "main"}}

Theres evidently something wrong with my KBUILD_MODSYM _dyndbg_site here,
the site pointers in all the headers appear the same,
but maybe its just an effect of initialization,
which I expect to reshape with a union - struct to use the space efficiently


(gdb) p *__start___dyndbg@10
$3 = {{site = 0x82b252e8 , format =
0x825a8ab9 "head64",
lineno = 0, flags = 0, module_index = 0, key = {dd_key_true = {key =
{enabled = {counter = 0}, {
type = 0, entries = 0x0 , next = 0x0
}}},
  dd_key_false = {key = {enabled = {counter = 0}, {type = 0, entries =
0x0 ,
next = 0x0 }, {site = 0x82b252e8
,
format = 0x825a8ade "ebda", lineno = 0, flags = 0, module_index
= 0, key = {dd_key_true = {
key = {enabled = {counter = 0}, {type = 0, entries = 0x0
,
next = 0x0 }}}, dd_key_false = {key =
{enabled = {counter = 0}, {type = 0,
entries = 0x0 , next = 0x0
}, {
site = 0x82b252e8 , format =
0x825a8ae3 "platform_quirks",
lineno = 0, flags = 0, module_index = 0, key = {dd_key_true = {key =
{enabled = {counter = 0}, {
type = 0, entries = 0x0 , next = 0x0
}}},
  dd_key_false = {key = {enabled = {counter = 0}, {type = 0, entries =
0x0 ,
next = 0x0 }, {
site = 0x82b25330 <__UNIQUE_ID_ddebug468_site.13>, format =
0x82653f07 "%s\n",
lineno = 1349, flags = 1, module_index = 0, key = {dd_key_true = {key =
{enabled = {counter = 1}, {
type = 18446744071602861249, entries = 0x826e74c1, next
= 0x826e74c1}}},
  dd_key_false = {key = {enabled = {counter = 1}, {type =
18446744071602861249,
entries = 0x826e74c1, next = 0x826e74c1}, {
site = 0x82b25348 <__UNIQUE_ID_ddebug467_site.15>,
format = 0x825a8b59 "  with environment:\n", lineno = 1347,
flags = 1, module_index = 0,
key = {dd_key_true = {key = {enabled = {counter = 1}, {type =
18446744071602861265,
entries = 0x826e74d1, next = 0x826e74d1}}},
dd_key_false = {key = {enabled = {
counter = 1}, {type = 18446744071602861265, entries =
0x826e74d1,
next = 0x826e74d1}, {site = 0x82b25360
<__UNIQUE_ID_ddebug466_site.17>,
format = 0x82653f07 "%s\n", lineno = 1346, flags = 1,
module_index = 0, key = {
  dd_key_true = {key = {enabled = {counter = 1}, {type =
18446744071602861281,
entries = 0x826e74e1, next = 0x826e74e1}}},
dd_key_false = {key = {enabled = {
counter = 1}, {type = 18446744071602861281, entries =
0x826e74e1,
next = 0x826e74e1}, {site = 0x82b25378
<__UNIQUE_ID_ddebug465_site.19>,
format = 0x825a8b46 "  with arguments:\n", lineno = 1344, flags
= 1, module_index = 0, key = {
  dd_key_true = {key = {enabled = {counter = 1}, {type =
18446744071602861297,


at any rate, I'll probly work this a bit, see if I can resolve a few
problems
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org

Re: '-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ?

2021-01-29 Thread jim . cromie
On Thu, Jan 28, 2021 at 5:16 PM  wrote:

>
>
> On Thu, Jan 28, 2021 at 4:57 PM Valdis Klētnieks 
> wrote:
>
>> On Thu, 28 Jan 2021 12:11:54 -0700, jim.cro...@gmail.com said:
>>
>> > In my hacking, Im finding this useful.
>> > it adds a version of KBUILD_MODNAME without the quotes
>>
>> OK, I'll bite.  When and how is this useful?
>>
>>
>
Let me add more context here.

1st, the long saga.

v1 - here, back in august last year.
https://lore.kernel.org/kernelnewbies/20200805183023.586590-1-jim.cro...@gmail.com/
not really pertinent here.
gregkh pretty much said send it to lkml

v2 - RFC to LKML
https://lore.kernel.org/lkml/20201225201944.3701590-1-jim.cro...@gmail.com/
this didnt get much attention, no answers to my questions
the  is still completely accurate, I cannot improve upon it,
though many questions in the commit messages Ive answered myself.
(or at least made some choices ;)

v3 - sits in github now
almost identical 1-16/19 with v2
https://github.com/jimc/linux.git dyndbg-next

I was hoping to pull off a context-free question,
focusing on just the Makefile.lib patch's suitability.

I could send the whole series here, or to LKML, or both.
I can hope a quick perusal will get you to the interesting parts


> heres my use
>
>
Im looking to define a module-unique header record,
and to create storage for it in a separate section.
Then append that section to the module's __dyndbg section.

The pragma is leftover scaffolding from trying to figure out
that I needed the _sym_ version also, without the quotes.
I un-commented for demo only.

#define DEFINE_DYNAMIC_DEBUG_TABLE_(_sym_,_mod_)   \
> weak struct _ddebug \
> __used __aligned(8) \
> __section(".gnu.linkonce." _mod_ ".dyndbg") \
> _sym_##_dyndbg_base = { \
> .site = &_sym_##_dyndbg_site, \
> .format = _mod_, \
> .lineno = 0 \
> }
>
> #define DEFINE_DYNAMIC_DEBUG_TABLE() \
> DEFINE_DYNAMIC_DEBUG_TABLE_(KBUILD_MODSYM, KBUILD_MODNAME);
>
>

I cannot make the _mod_ ## work at the same time as
allowing "foo" _mod_ "buzz" catenation, therefore the new _sym_


This DEFINE is "called" from the bottom of include/linux/dynamic_debug.h

the combo of weak and ".gnu.linkonce." appear to resolve all
all the redundant definitions created by each C files' inclusion
of the header.
Inspiration came from .gnu.linkonce.this_module


--- a/include/asm-generic/vmlinux.lds.h

+++ b/include/asm-generic/vmlinux.lds.h

@@ -329,10 +329,10 @@

#define DYNAMIC_DEBUG_DATA() \

. = ALIGN(8); \

__start___dyndbg_sites = .; \

- KEEP(*(__dyndbg_sites __dyndbg_sites.header)) \

+ KEEP(*(__dyndbg_sites .gnu.linkonce.*.dyndbg_site)) \

__stop___dyndbg_sites = .; \

__start___dyndbg = .; \

- KEEP(*(__dyndbg __dyndbg.header)) \

+ KEEP(*(__dyndbg .gnu.linkonce.*.dyndbg)) \

__stop___dyndbg = .;

#else

#define DYNAMIC_DEBUG_DATA()

that puts the header record into the output section, right after the
module's
set of ddebug's (pr_debug callsite descriptors)

By getting the header into a fixed position relative to a callsite,
its possible to go from callsite-descriptor to the header
(after .module_index is initialized with the offset, determined at _init),
then use a single per-module pointer to the separate vector of "decorator"
data.

Once the 2 vectors of __dyndbg and __dyndbg_site records are indexed by N,
I can drop the .site pointer from 1 to other, and shrink the footprint back
to
~parity (with + 1 record / module overhead) worst case.

with 2 vectors fully decoupled (pointer-wise),
the decorator records can be stuffed into compressed block storage,
zram, etc, then recovered when a callsite is enabled,
and saved into a hashtable, indexed by modname+module-index.
global/module hash per experiment.

Anyway, I appear to have gotten the header where I want it:

[0.315519] dyndbg: header: head64 0
[0.326702] dyndbg: header: ebda 0
[0.342521] dyndbg: header: platform_quirks 0
[0.373523] dyndbg: site.4: main run_init_process
[0.406518] dyndbg: site.5: main run_init_process
[0.437521] dyndbg: site.6: main run_init_process
[0.468521] dyndbg: site.7: main run_init_process
[0.500528] dyndbg: site.8: main initcall_blacklisted
[0.531519] dyndbg: site.9: main initcall_blacklist
[0.20] dyndbg: header: main 0

I have extra headers right now,
head64 ebda platform_quirks above,
for modules that have no pr-debug callsites.

Thats a problem for later,
though I posted here about conditional linkage earlier.

Im afraid it needs an ld linker language enhancement:
KEEP( IF *(__dyndbg) THEN (.gnu.linkonce.dyndbg) )

but Ive yet to try a simpler boolean algrebra
KEEP( *(__dyndbg && .gnu.linkonce.dyndbg))

if by some miracle that works, I'll report that shortly.

>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: '-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ?

2021-01-28 Thread jim . cromie
On Thu, Jan 28, 2021 at 4:57 PM Valdis Klētnieks 
wrote:

> On Thu, 28 Jan 2021 12:11:54 -0700, jim.cro...@gmail.com said:
>
> > In my hacking, Im finding this useful.
> > it adds a version of KBUILD_MODNAME without the quotes
>
> OK, I'll bite.  When and how is this useful?
>
>
heres my use

#define DEFINE_DYNAMIC_DEBUG_TABLE_(_sym_,_mod_)   \
weak struct _ddebug \
__used __aligned(8) \
__section(".gnu.linkonce." _mod_ ".dyndbg") \
_sym_##_dyndbg_base = { \
.site = &_sym_##_dyndbg_site, \
.format = _mod_, \
.lineno = 0 \
}

#pragma message "OK<" KBUILD_MODNAME ">[" __stringify(KBUILD_MODSYM) "]
adding DYNDBG_TABLE"

#define DEFINE_DYNAMIC_DEBUG_TABLE() \
DEFINE_DYNAMIC_DEBUG_TABLE_(KBUILD_MODSYM, KBUILD_MODNAME);

that pragma does:

 from /home/jimc/projects/lx/wk-next/init/version.c:14:
/home/jimc/projects/lx/wk-next/include/linux/dynamic_debug.h:172:9: note:
‘#pragma message: OK[version] adding DYNDBG_TABLE’
  172 | #pragma message "OK<" KBUILD_MODNAME ">["
__stringify(KBUILD_MODSYM) "] adding DYNDBG_TABLE"
  | ^~~
  CC  init/do_mounts.o

IOW the _sym_ works better for ## token-joining


> KBUILD_MODNAME has the quotes for a reason;
>
> Hint:  do a "git grep KBUILD_MODNAME", look at how it's used, and
> think about how invasive a patch to change it would be...
> (And pay heed to the comment in arch/sparc/include/asm/vio.h -
> it means that there's second-order effects to deal with as well...)
>
>
I have no intention of changing KBUILD_MODNAME.
I created a near-synonym to avoid exactly that.



> > Afterall, __stringify() could add the quotes for cases where it was
> needed.Afterall, __stringify() could add the quotes for cases where it was
> needed.
>
> How would it know?
>

It would not.
you would add it to create the quoted version, as I used in the pragma.
obviously theres no need, since KBUILD_MODNAME already exists.

So question reduces to:

is there anything brittle with the Makefile -DKBUILD_MODSYM=$modname
addition ?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


'-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ?

2021-01-28 Thread jim . cromie
hi folks,

In my hacking, Im finding this useful.
it adds a version of KBUILD_MODNAME without the quotes

--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -119,7 +119,7 @@ target-stem = $(basename $(patsubst $(obj)/%,%,$@))
 # end up in (or would, if it gets compiled in)
 name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1)))
 basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
-modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname))
+modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname))
-DKBUILD_MODSYM=$(modname)


Im suspicious however,
KBUILD_MODNAME has the quotes for a reason;
probably robustness at some level.
Afterall, __stringify() could add the quotes for cases where it was needed.

If there was an __unstringify_token( ) I could remove this Makefile hack,
is such a construct possible ?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


  1   2   >