Skip to content

Store required patches in codestream object#170

Merged
fgyanz merged 14 commits intoSUSE:develfrom
vmezzela:filter-patches
Dec 23, 2025
Merged

Store required patches in codestream object#170
fgyanz merged 14 commits intoSUSE:develfrom
vmezzela:filter-patches

Conversation

@vmezzela
Copy link
Collaborator

This is an initial reorganization of the code around scan and the way we store the patches in preparation for fixing #153 .

The final fix can be implemented only after #160 is merged since that PR drops the use of quilt to apply the patches, which makes it more easy to selectively apply them.

I took the chance to further refactor scan. What was done before is:

  1. Retrieve the filtered codestreams
  2. First loop on them to retrieve the patched kernels (using get_patched_kernels())
  3. Second loop on the filtered codestreams to check these whose kernel belong to the list of patched_kernels, otherwise add them either to working_cs or unaffected_cs (or skipping due to missing support for arch)

The unnecessary thing was that we were storing the cs.kernel in patched_kernels when filtering with get_patched_kernels(). And then afterward we were checking which codestreams had that kernel with if cs.kernel in patched_kernels. This has been simplified by just filtering the patched codestreams (rather than their kernel). With this, a whole loop has been dropped because unneeded.

Now the process is:

  1. Retrieve the filtered codestreams
  2. Loop over the filtered codestreams and filter it into affected_cs, unaffected_cs, patched_cs (in the same loop)

Avoiding the unneeded patched_kernel.add(cs.kernel) and then cs -> cs.kernel -> if cs.kernel in patched_cs -> patched_cs.append(cs) steps.

Besides that, the most notable part is that now the required patches are stored in the codestream object directly, so that we can just retrieve the patches from there on a per codestream basis rather than on a per product basis, effectively introducing the possibility to perform the patch analysis only on those that are needed. And same goes for the extraction where we will be able to apply only the needed ones.

This is yet to be tested. I am posting this PR in advance to help coordinate the work across different PRs.

Copy link
Collaborator

@fgyanz fgyanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool @vmezzela !! I like the changes, just some minor comments.

@vmezzela
Copy link
Collaborator Author

@fgyanz comments addressed!

@marcosps
Copy link
Collaborator

@vmezzela can we already review? :D

@vmezzela
Copy link
Collaborator Author

Hi Marcos, I'll mark this as ready to be reviewed when I rebase it on the latest devel.

@vmezzela vmezzela force-pushed the filter-patches branch 4 times, most recently from 7b912bc to 7dbb731 Compare December 18, 2025 13:40
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
@vmezzela vmezzela marked this pull request as ready for review December 19, 2025 10:37
@vmezzela vmezzela requested review from fgyanz and marcosps December 19, 2025 10:37

def get_patched_kernels(codestreams, patches):
def filter_affected_codestreams(codestreams, patches):
# TODO: remove this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it removed in a following commit? :D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair :)

Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
In this way, if no patches are supplied, all the codestreams will go in
the unaffected_codestreams list

Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
This is in preparation to make apply_all_patches aware of patches
already present on each codestreams so that it can skip those.

This patch also drops logging.debug("Patches dir %s doesnt exists",
pdir) as it's kind of redundant with the next logs.

Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Signed-off-by: Vincenzo Mezzela <vincenzo.mezzela@suse.com>
Copy link
Collaborator

@marcosps marcosps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@fgyanz fgyanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and tested. I proposed a small cosmetic change but by no means mandatory. Thanks a lot for the changes, LGTM!! 🥳

logging.info("\tDropping %s", patch_name)
continue

logging.info("\tApplying %s", patch_name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much nitpicking, but I'd propose keeping the previous log message. It's a purely cosmetic change, but I think it keeps more consistent with klp-build logs format.

before:

[2025-11-18 22:05:52] 15.5u30:5.14.21-150500.55.121: Applying /home/fgonzalez/klp/livepatches/bsc1251984/fixes/15.5/01-wifi-rtw88-delete-timer-and-free-skb-queue-when-unlo.patch...
[2025-11-18 22:05:53] Patches dir /home/fgonzalez/klp/livepatches/bsc1251984/fixes/15.5u31 doesnt exists
[2025-11-18 22:05:53] Applying patches on 15.5u31(5.14.21-150500.55.124) from /home/fgonzalez/klp/livepatches/bsc1251984/fixes/15.5
[2025-11-18 22:05:53] 15.5u31:5.14.21-150500.55.124: Applying /home/fgonzalez/klp/livepatches/bsc1251984/fixes/15.5/01-wifi-rtw88-delete-timer-and-free-skb-queue-when-unlo.patch...

now:

Applying patches on 15.5u29(5.14.21-150500.55.116) from /home/fgonzalez/klp/livepatches/bsc1251984/fixes/15.5
	Applying wifi-rtw88-delete-timer-and-free-skb-queue-when-unlo.patch
Applying patches on 15.5u30(5.14.21-150500.55.121) from /home/fgonzalez/klp/livepatches/bsc1251984/fixes/15.5
	Applying wifi-rtw88-delete-timer-and-free-skb-queue-when-unlo.patch
Applying patches on 15.5u31(5.14.21-150500.55.124) from /home/fgonzalez/klp/livepatches/bsc1251984/fixes/15.5
	Applying wifi-rtw88-delete-timer-and-free-skb-queue-when-unlo.patch

@fgyanz fgyanz merged commit ce62e0b into SUSE:devel Dec 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants