Commit Graph

1157273 Commits

Author SHA1 Message Date
Greg Kroah-Hartman
ee16988743 Merge 6.1.65 into android14-6.1-lts
Changes in 6.1.65
	afs: Fix afs_server_list to be cleaned up with RCU
	afs: Make error on cell lookup failure consistent with OpenAFS
	drm/panel: boe-tv101wum-nl6: Fine tune the panel power sequence
	drm/panel: auo,b101uan08.3: Fine tune the panel power sequence
	drm/panel: simple: Fix Innolux G101ICE-L01 bus flags
	drm/panel: simple: Fix Innolux G101ICE-L01 timings
	wireguard: use DEV_STATS_INC()
	octeontx2-pf: Fix memory leak during interface down
	ata: pata_isapnp: Add missing error check for devm_ioport_map()
	drm/i915: do not clean GT table on error path
	drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full
	HID: fix HID device resource race between HID core and debugging support
	ipv4: Correct/silence an endian warning in __ip_do_redirect
	net: usb: ax88179_178a: fix failed operations during ax88179_reset
	net/smc: avoid data corruption caused by decline
	arm/xen: fix xen_vcpu_info allocation alignment
	octeontx2-pf: Fix ntuple rule creation to direct packet to VF with higher Rx queue than its PF
	amd-xgbe: handle corner-case during sfp hotplug
	amd-xgbe: handle the corner-case during tx completion
	amd-xgbe: propagate the correct speed and duplex status
	net: axienet: Fix check for partial TX checksum
	afs: Return ENOENT if no cell DNS record can be found
	afs: Fix file locking on R/O volumes to operate in local mode
	mm,kfence: decouple kfence from page granularity mapping judgement
	arm64: mm: Fix "rodata=on" when CONFIG_RODATA_FULL_DEFAULT_ENABLED=y
	i40e: use ERR_PTR error print in i40e messages
	i40e: Fix adding unsupported cloud filters
	nvmet: nul-terminate the NQNs passed in the connect command
	USB: dwc3: qcom: fix resource leaks on probe deferral
	USB: dwc3: qcom: fix ACPI platform device leak
	lockdep: Fix block chain corruption
	cifs: minor cleanup of some headers
	smb3: allow dumping session and tcon id to improve stats analysis and debugging
	cifs: print last update time for interface list
	cifs: distribute channels across interfaces based on speed
	cifs: account for primary channel in the interface list
	cifs: fix leak of iface for primary channel
	MIPS: KVM: Fix a build warning about variable set but not used
	media: camss: Split power domain management
	media: camss: Convert to platform remove callback returning void
	media: qcom: Initialise V4L2 async notifier later
	media: qcom: camss: Fix V4L2 async notifier error path
	media: qcom: camss: Fix genpd cleanup
	ext4: add a new helper to check if es must be kept
	ext4: factor out __es_alloc_extent() and __es_free_extent()
	ext4: use pre-allocated es in __es_insert_extent()
	ext4: use pre-allocated es in __es_remove_extent()
	ext4: using nofail preallocation in ext4_es_remove_extent()
	ext4: using nofail preallocation in ext4_es_insert_delayed_block()
	ext4: using nofail preallocation in ext4_es_insert_extent()
	ext4: fix slab-use-after-free in ext4_es_insert_extent()
	ext4: make sure allocate pending entry not fail
	NFSD: Fix "start of NFS reply" pointer passed to nfsd_cache_update()
	NFSD: Fix checksum mismatches in the duplicate reply cache
	arm64: dts: imx8mn-var-som: add 20ms delay to ethernet regulator enable
	ACPI: resource: Skip IRQ override on ASUS ExpertBook B1402CVA
	swiotlb-xen: provide the "max_mapping_size" method
	bcache: replace a mistaken IS_ERR() by IS_ERR_OR_NULL() in btree_gc_coalesce()
	md: fix bi_status reporting in md_end_clone_io
	bcache: fixup multi-threaded bch_sectors_dirty_init() wake-up race
	io_uring/fs: consider link->flags when getting path for LINKAT
	s390/dasd: protect device queue against concurrent access
	USB: serial: option: add Luat Air72*U series products
	hv_netvsc: fix race of netvsc and VF register_netdevice
	hv_netvsc: Fix race of register_netdevice_notifier and VF register
	hv_netvsc: Mark VF as slave before exposing it to user-mode
	dm-delay: fix a race between delay_presuspend and delay_bio
	bcache: check return value from btree_node_alloc_replacement()
	bcache: prevent potential division by zero error
	bcache: fixup init dirty data errors
	bcache: fixup lock c->root error
	usb: cdnsp: Fix deadlock issue during using NCM gadget
	USB: serial: option: add Fibocom L7xx modules
	USB: serial: option: fix FM101R-GL defines
	USB: serial: option: don't claim interface 4 for ZTE MF290
	usb: typec: tcpm: Skip hard reset when in error recovery
	USB: dwc2: write HCINT with INTMASK applied
	usb: dwc3: Fix default mode initialization
	usb: dwc3: set the dma max_seg_size
	USB: dwc3: qcom: fix software node leak on probe errors
	USB: dwc3: qcom: fix wakeup after probe deferral
	io_uring: fix off-by one bvec index
	Linux 6.1.65

Change-Id: Iea9267bee56905028a77d03c7fad8def8969246e
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-12-20 13:31:28 +00:00
Greg Kroah-Hartman
a01e106f08 Merge branch 'android14-6.1' into branch 'android14-6.1-lts'
This catches the android14-6.1-lts branch up with the latest changes and
abi updates.  Included in here are the following commits:

07775f9683 ANDROID: GKI: Add symbols for rockchip sata
f44d373b32 ANDROID: sched: Add trace_android_rvh_setscheduler
efa8f34b5a ANDROID: Update the ABI symbol list
cee8ebf7c5 ANDROID: GKI: build damon for monitoring virtual address spaces
31c59d59c7 UPSTREAM: mm/damon/sysfs-schemes: handle tried region directory allocation failure
1cedfc05e9 UPSTREAM: mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure
7fbeab3c65 UPSTREAM: mm/damon/sysfs: check error from damon_sysfs_update_target()
606444fd06 UPSTREAM: mm/damon/sysfs: eliminate potential uninitialized variable warning
c132d077eb UPSTREAM: mm/damon/sysfs: update monitoring target regions for online input commit
6b7c4cc262 UPSTREAM: mm/damon/sysfs: remove requested targets when online-commit inputs
1e19db10e7 UPSTREAM: mm/damon/sysfs: avoid empty scheme tried regions for large apply interval
c194e597cb UPSTREAM: mm/damon/sysfs-schemes: do not update tried regions more than one DAMON snapshot
f5a0a8bc43 UPSTREAM: mm/damon/sysfs: check DAMOS regions update progress from before_terminate()
b46391e092 UPSTREAM: mm/damon/sysfs: implement a command for updating only schemes tried total bytes
7d48e19f74 UPSTREAM: mm/damon/sysfs-schemes: implement DAMOS tried total bytes file
a548d90994 UPSTREAM: mm/damon/ops-common: refactor to use {pte|pmd}p_clear_young_notify()
ea215c9a10 UPSTREAM: mm/damon/core: skip apply schemes if empty
3ca21ef5fa UPSTREAM: mm/damon: use kstrtobool() instead of strtobool()
5bf7b56860 UPSTREAM: mm/damon/sysfs-schemes: implement DAMOS-tried regions clear command
80ccab9b0e UPSTREAM: mm/damon/sysfs: implement DAMOS tried regions update command
3421250b35 UPSTREAM: mm/damon/sysfs-schemes: implement scheme region directory
b4c34cc168 UPSTREAM: mm/damon/sysfs-schemes: implement schemes/tried_regions directory
b5d1f3576b UPSTREAM: mm/damon/core: add a callback for scheme target regions check
6547a97f32 UPSTREAM: mm/damon/lru_sort: enable and disable synchronously
540e9b850d UPSTREAM: mm/damon/reclaim: enable and disable synchronously
4e2d3f8e31 UPSTREAM: mm/damon/{reclaim,lru_sort}: remove unnecessarily included headers
3c0bc73f6e UPSTREAM: mm/damon/modules: deduplicate init steps for DAMON context setup
67ef7b0f42 UPSTREAM: mm/damon/sysfs: split out schemes directory implementation to separate file
0b17df8a4f UPSTREAM: mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new function
a45dff567c UPSTREAM: mm/damon/sysfs: move unsigned long range directory to common module
c5038d80ce UPSTREAM: mm/damon/sysfs: move sysfs_lock to common module
b7fc8d59a5 UPSTREAM: mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc()
19364f11a4 UPSTREAM: mm/damon/sysfs: use damon_addr_range for region's start and end values
b6e6b1dbf8 UPSTREAM: mm/damon/core: split out scheme quota adjustment logic into a new function
43475d9708 UPSTREAM: mm/damon/core: split out scheme stat update logic into a new function
0b0a43029e UPSTREAM: mm/damon/core: split damos application logic into a new function
6c7495f04a UPSTREAM: mm/damon/core: split out DAMOS-charged region skip logic into a new function
ac1031618a ANDROID: Snapshot Mainline's version of checkpatch.pl
4fa87d4d8f ANDROID: KVM: arm64: Skip prefaulting ptes which will be modified later
fbc707442c ANDROID: KVM: arm64: Introduce module_change_host_prot_range
fd720ebc6a ANDROID: KVM: arm64: Relax checks in module_change_host_page_prot
f082d22541 ANDROID: KVM: arm64: Optimise module_change_host_page_prot
01dd8c280b ANDROID: KVM: arm64: Prefault entries when splitting a block mapping
cc653d701f ANDROID: virt: gunyah: Zero state_data after vcpu_run
cc294d9503 ANDROID: Update the ABI symbol list
956a0d3998 ANDROID: fs: Add vendor hooks for ep_create_wakeup_source & timerfd_create
d8d2b95fd0 ANDROID: ABI: update symbol list for galaxy
bcc758eed7 Reapply "binder: fix UAF caused by faulty buffer cleanup"
b2b3a1e6d1 UPSTREAM: x86/sev: Check for user-space IOIO pointing to kernel space
62b97630d4 UPSTREAM: x86/sev: Check IOBM for IOIO exceptions from user-space
071c14698c FROMGIT: usb: typec: tcpm: skip checking port->send_discover in PD3.0
a9567a35d0 ANDROID: arm64: Disable workaround for CPU errata 2441007 and 2441009

Change-Id: Icbda2fae389ea4c2e7230821c59ac0380a35d756
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-12-19 19:05:29 +00:00
Kever Yang
07775f9683 ANDROID: GKI: Add symbols for rockchip sata
INFO: 24 function symbol(s) added
  'size_t __scsi_format_command(char*, size_t, const unsigned char*, size_t)'
  'int attribute_container_register(struct attribute_container*)'
  'int attribute_container_unregister(struct attribute_container*)'
  'void pci_intx(struct pci_dev*, int)'
  'int pcim_iomap_regions_request_all(struct pci_dev*, int, const char*)'
  'void pcim_pin_device(struct pci_dev*)'
  'int reset_control_rearm(struct reset_control*)'
  'enum scsi_disposition scsi_check_sense(struct scsi_cmnd*)'
  'int scsi_device_set_state(struct scsi_device*, enum scsi_device_state)'
  'void scsi_eh_finish_cmd(struct scsi_cmnd*, struct list_head*)'
  'void scsi_eh_flush_done_q(struct list_head*)'
  'int scsi_rescan_device(struct scsi_device*)'
  'void scsi_schedule_eh(struct Scsi_Host*)'
  'const u8* scsi_sense_desc_find(const u8*, int, int)'
  'int scsi_set_sense_field_pointer(u8*, int, u16, u8, bool)'
  'void sdev_evt_send_simple(struct scsi_device*, enum scsi_device_event, gfp_t)'
  'bool system_entering_hibernation()'
  'int transport_add_device(struct device*)'
  'int transport_class_register(struct transport_class*)'
  'void transport_class_unregister(struct transport_class*)'
  'void transport_configure_device(struct device*)'
  'void transport_destroy_device(struct device*)'
  'void transport_remove_device(struct device*)'
  'void transport_setup_device(struct device*)'

Bug: 300024866
Change-Id: I6a505d48d0d199a710b0d93b6a8df189735a7b89
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2023-12-19 18:44:06 +00:00
Rick Yiu
f44d373b32 ANDROID: sched: Add trace_android_rvh_setscheduler
Sync to android13-5.10. This vendor hook is declared already.

Bug: 245675204
Change-Id: Ib081b52542380d22317f225a50b553cda5f2634c
Signed-off-by: Rick Yiu <rickyiu@google.com>
(cherry picked from commit f9688670ca92bf9f46f9a6134bc69623c30bbb23)
2023-12-19 09:04:16 +00:00
John Scheible
efa8f34b5a ANDROID: Update the ABI symbol list
Adding the following symbols:
  - dma_fence_enable_sw_signaling
  - dma_fence_unwrap_first
  - __dma_fence_unwrap_merge
  - dma_fence_unwrap_next

3 function symbol(s) added
  'struct dma_fence* __dma_fence_unwrap_merge(unsigned int, struct dma_fence**, struct dma_fence_unwrap*)'
  'struct dma_fence* dma_fence_unwrap_first(struct dma_fence*, struct dma_fence_unwrap*)'
  'struct dma_fence* dma_fence_unwrap_next(struct dma_fence_unwrap*)'

Bug: 316212868
Change-Id: I41a4d906e98c983c4b612f65127bd7ef7ac5cb85
Signed-off-by: John Scheible <johnscheible@google.com>
2023-12-19 03:09:43 +00:00
cuiyangpei
cee8ebf7c5 ANDROID: GKI: build damon for monitoring virtual address spaces
Enable damon related configs in gki_defconfig.

Bug: 300502883
Change-Id: Ie00a923464d2f1fff8f12a8804cbac040f0cacdf
Signed-off-by: cuiyangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
31c59d59c7 UPSTREAM: mm/damon/sysfs-schemes: handle tried region directory allocation failure
DAMON sysfs interface's before_damos_apply callback
(damon_sysfs_before_damos_apply()), which creates the DAMOS tried regions
for each DAMOS action applied region, is not handling the allocation
failure for the sysfs directory data.  As a result, NULL pointer
derefeence is possible.  Fix it by handling the case.

Link: https://lkml.kernel.org/r/20231106233408.51159-4-sj@kernel.org
Fixes: f1d13cacabe1 ("mm/damon/sysfs: implement DAMOS tried regions update command")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[6.2+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit ae636ae2bbfd9279f5681dbf320d1da817e52b68)

Bug: 300502883
Change-Id: I98568f4b0cee9fea82f4fe6d3e7a505370c3c304
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
1cedfc05e9 UPSTREAM: mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure
DAMOS tried regions sysfs directory allocation function
(damon_sysfs_scheme_regions_alloc()) is not handling the memory allocation
failure.  In the case, the code will dereference NULL pointer.  Handle the
failure to avoid such invalid access.

Link: https://lkml.kernel.org/r/20231106233408.51159-3-sj@kernel.org
Fixes: 9277d0367ba1 ("mm/damon/sysfs-schemes: implement scheme region directory")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[6.2+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 84055688b6bc075c92a88e2d6c3ad26ab93919f9)

Bug: 300502883
Change-Id: I86ecb2f3cf1604199b5567576b1fa583914f7f36
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
7fbeab3c65 UPSTREAM: mm/damon/sysfs: check error from damon_sysfs_update_target()
Patch series "mm/damon/sysfs: fix unhandled return values".

Some of DAMON sysfs interface code is not handling return values from some
functions.  As a result, confusing user input handling or NULL-dereference
is possible.  Check those properly.

This patch (of 3):

damon_sysfs_update_target() returns error code for failures, but its
caller, damon_sysfs_set_targets() is ignoring that.  The update function
seems making no critical change in case of such failures, but the behavior
will look like DAMON sysfs is silently ignoring or only partially
accepting the user input.  Fix it.

Link: https://lkml.kernel.org/r/20231106233408.51159-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20231106233408.51159-2-sj@kernel.org
Fixes: 19467a950b49 ("mm/damon/sysfs: remove requested targets when online-commit inputs")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[5.19+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit b4936b544b08ed44949055b92bd25f77759ebafc)

Bug: 300502883
Change-Id: I9bfea66f76ad094ed73defee5ff3fdb3794e8162
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
Dan Carpenter
606444fd06 UPSTREAM: mm/damon/sysfs: eliminate potential uninitialized variable warning
The "err" variable is not initialized if damon_target_has_pid(ctx) is
false and sys_target->regions->nr is zero.

Link: https://lkml.kernel.org/r/739e6aaf-a634-4e33-98a8-16546379ec9f@moroto.mountain
Fixes: 0bcd216c4741 ("mm/damon/sysfs: update monitoring target regions for online input commit")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 85c2ceaafbd306814a3a4740bf4d95ac26a8b36a)

Bug: 300502883
Change-Id: I235ea1bfc9d8bf0fef426dbc21881d755e3a5d67
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
c132d077eb UPSTREAM: mm/damon/sysfs: update monitoring target regions for online input commit
When user input is committed online, DAMON sysfs interface is ignoring the
user input for the monitoring target regions.  Such request is valid and
useful for fixed monitoring target regions-based monitoring ops like
'paddr' or 'fvaddr'.

Update the region boundaries as user specified, too.  Note that the
monitoring results of the regions that overlap between the latest
monitoring target regions and the new target regions are preserved.

Treat empty monitoring target regions user request as a request to just
make no change to the monitoring target regions.  Otherwise, users should
set the monitoring target regions same to current one for every online
input commit, and it could be challenging for dynamic monitoring target
regions update DAMON ops like 'vaddr'.  If the user really need to remove
all monitoring target regions, they can simply remove the target and then
create the target again with empty target regions.

Link: https://lkml.kernel.org/r/20231031170131.46972-1-sj@kernel.org
Fixes: da87878010 ("mm/damon/sysfs: support online inputs update")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[5.19+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 9732336006764e2ee61225387e3c70eae9139035)

Bug: 300502883
Change-Id: I6857482470951382c9be36f2099da76e9b71d502
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
6b7c4cc262 UPSTREAM: mm/damon/sysfs: remove requested targets when online-commit inputs
damon_sysfs_set_targets(), which updates the targets of the context for
online commitment, do not remove targets that removed from the
corresponding sysfs files.  As a result, more than intended targets of the
context can exist and hence consume memory and monitoring CPU resource
more than expected.

Fix it by removing all targets of the context and fill up again using the
user input.  This could cause unnecessary memory dealloc and realloc
operations, but this is not a hot code path.  Also, note that damon_target
is stateless, and hence no data is lost.

[sj@kernel.org: fix unnecessary monitoring results removal]
  Link: https://lkml.kernel.org/r/20231028213353.45397-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20231022210735.46409-2-sj@kernel.org
Fixes: da87878010 ("mm/damon/sysfs: support online inputs update")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: <stable@vger.kernel.org>	[5.19.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 19467a950b49432a84bf6dbadbbb17bdf89418b7)

Bug: 300502883
Change-Id: Icf094f138e6810182d23d2c412fbabe3ecd960fe
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
1e19db10e7 UPSTREAM: mm/damon/sysfs: avoid empty scheme tried regions for large apply interval
DAMON_SYSFS assumes all schemes will be applied for at least one DAMON
monitoring results snapshot within one aggregation interval, or makes no
sense to wait for it while DAMON is deactivated by the watermarks.  That
for deactivated status still makes sense, but the aggregation interval
based assumption is invalid now because each scheme can has its own apply
interval.  For schemes having larger than the aggregation or watermarks
check interval, DAMOS tried regions update request can be finished without
the update.  Avoid the case by explicitly checking the status of the
schemes tried regions update and watermarks based DAMON deactivation.

Link: https://lkml.kernel.org/r/20231012192256.33556-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 76126332c7606ba25a4ae5db37145fd526985b45)

Bug: 300502883
Change-Id: I8283709a023123d7a89fd37a1d4a834888c15c7e
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
c194e597cb UPSTREAM: mm/damon/sysfs-schemes: do not update tried regions more than one DAMON snapshot
Patch series "mm/damon/sysfs-schemes: Do DAMOS tried regions update for
only one apply interval".

DAMOS tried regions update feature of DAMON sysfs interface is doing the
update for one aggregation interval after the request is made.  Since the
per-scheme apply interval is supported, that behavior makes no much sense.
That is, the tried regions directory will have regions from multiple
DAMON monitoring results snapshots, or no region for apply intervals that
much shorter than, or longer than the aggregation interval, respectively.
Update the behavior to update the regions for each scheme for only its
apply interval, and update the document.

Since DAMOS apply interval is the aggregation by default, this change
makes no visible behavioral difference to old users who don't explicitly
set the apply intervals.

Patches Sequence
----------------

The first two patches makes schemes of apply intervals that much shorter
or longer than the aggregation interval to keep the maximum and minimum
times for continuing the update.  After the two patches, the update aligns
with the each scheme's apply interval.

Finally, the third patch updates the document to reflect the behavior.

This patch (of 3):

DAMON_SYSFS exposes every DAMON-found region that eligible for applying
the scheme action for one aggregation interval.  However, each DAMON-based
operation scheme has its own apply interval.  Hence, for a scheme that
having its apply interval much smaller than the aggregation interval,
DAMON_SYSFS will expose the scheme regions that applied to more than one
DAMON monitoring results snapshots.  Since the purpose of DAMON tried
regions is exposing single snapshot, this makes no much sense.  Track
progress of each scheme's tried regions update and avoid the case.

Link: https://lkml.kernel.org/r/20231012192256.33556-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20231012192256.33556-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 4d4e41b682990b1dc5bba2bc313800340bf5c2d4)

Bug: 300502883
Change-Id: I78602a6810a9b4d8d131c3ace69f255ac1349d13
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
f5a0a8bc43 UPSTREAM: mm/damon/sysfs: check DAMOS regions update progress from before_terminate()
DAMON_SYSFS can receive DAMOS tried regions update request while kdamond
is already out of the main loop and before_terminate callback
(damon_sysfs_before_terminate() in this case) is not yet called.  And
damon_sysfs_handle_cmd() can further be finished before the callback is
invoked.  Then, damon_sysfs_before_terminate() unlocks damon_sysfs_lock,
which is not locked by anyone.  This happens because the callback function
assumes damon_sysfs_cmd_request_callback() should be called before it.
Check if the assumption was true before doing the unlock, to avoid this
problem.

Link: https://lkml.kernel.org/r/20231007200432.3110-1-sj@kernel.org
Fixes: f1d13cacabe1 ("mm/damon/sysfs: implement DAMOS tried regions update command")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[6.2.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 76b7069bcc89dec33f03eb08abee165d0306b754)

Bug: 300502883
Change-Id: I7cd5e00c0d0226dc8d7856d103f88a26307cafce
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
b46391e092 UPSTREAM: mm/damon/sysfs: implement a command for updating only schemes tried total bytes
Using tried_regions/total_bytes file, users can efficiently retrieve the
total size of memory regions having specific access pattern.  However,
DAMON sysfs interface in kernel still populates all the infomration on the
tried_regions subdirectories.  That means the kernel part overhead for the
construction of tried regions directories still exists.  To remove the
overhead, implement yet another command input for 'state' DAMON sysfs
file.  Writing the input to the file makes DAMON sysfs interface to update
only the total_bytes file.

Link: https://lkml.kernel.org/r/20230802213222.109841-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 6ad243b83b5094026fdb3171711ddb25246b3d8a)

Bug: 300502883
Change-Id: Id0bdf13858d6a92de0eeef22f59a65ee884e9d20
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
7d48e19f74 UPSTREAM: mm/damon/sysfs-schemes: implement DAMOS tried total bytes file
Patch series "mm/damon/sysfs-schemes: implement DAMOS tried total bytes
file".

The tried_regions directory of DAMON sysfs interface is useful for
retrieving monitoring results snapshot or DAMOS debugging.  However, for
common use case that need to monitor only the total size of the scheme
tried regions (e.g., monitoring working set size), the kernel overhead for
directory construction and user overhead for reading the content could be
high if the number of monitoring region is not small.  This patchset
implements DAMON sysfs files for efficient support of the use case.

The first patch implements the sysfs file to reduce the user space
overhead, and the second patch implements a command for reducing the
kernel space overhead.

The third patch adds a selftest for the new file, and following two
patches update documents.

[1] https://lore.kernel.org/damon/20230728201817.70602-1-sj@kernel.org/

This patch (of 5):

The tried_regions directory can be used for retrieving the monitoring
results snapshot for regions of specific access pattern, by setting the
scheme's action as 'stat' and the access pattern as required.  While the
interface provides every detail of the monitoring results, some use cases
including working set size monitoring requires only the total size of the
regions.  For such cases, users should read all the information and
calculate the total size of the regions.  However, it could incur high
overhead if the number of regions is high.  Add a file for retrieving only
the information, namely 'total_bytes' file.  It allows users to get the
total size by reading only the file.

Link: https://lkml.kernel.org/r/20230802213222.109841-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20230802213222.109841-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit b69f92a741405336fb17a8a3d67fc144192fe8e2)

Bug: 300502883
Change-Id: I49c225d15ba09a9b896341da14cc9f2b45578da7
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
Ryan Roberts
a548d90994 UPSTREAM: mm/damon/ops-common: refactor to use {pte|pmd}p_clear_young_notify()
With the fix in place to atomically test and clear young on ptes and pmds,
simplify the code to handle the clearing for both the primary mmu and the
mmu notifier with a single API call.

Link: https://lkml.kernel.org/r/20230602092949.545577-4-ryan.roberts@arm.com
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Acked-by: Yu Zhao <yuzhao@google.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit fa8c919dac3f5f325b17f9fcf8ac7dd899992598)

Bug: 300502883
Change-Id: I4414604788996e338ac638c3eb3ec1ef7959223e
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
Huaisheng Ye
ea215c9a10 UPSTREAM: mm/damon/core: skip apply schemes if empty
Sometimes there is no scheme in damon's context, for example just use damo
record to monitor workload's data access pattern.

If current damon context doesn't have any scheme in the list, kdamond has
no need to iterate over list of all targets and regions but do nothing.

So, skip apply schemes when ctx->schemes is empty.

Link: https://lkml.kernel.org/r/20230116062347.1148553-1-huaisheng.ye@intel.com
Signed-off-by: Huaisheng Ye <huaisheng.ye@intel.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 64517d6e1291b5e942b00c53674ecf33f918313f)

Bug: 300502883
Change-Id: Ic76ca90c85dbb24205b17dd914f91a8dd4cf7345
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
Christophe JAILLET
3ca21ef5fa UPSTREAM: mm/damon: use kstrtobool() instead of strtobool()
strtobool() is the same as kstrtobool().  However, the latter is more used
within the kernel.

In order to remove strtobool() and slightly simplify kstrtox.h, switch to
the other function name.

While at it, include the corresponding header file (<linux/kstrtox.h>)

Link: https://lkml.kernel.org/r/ed2b46489a513988688decb53850339cc228940c.1667336095.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit e6aff38b2e25e934e95471351c96d1410bb17561)

Bug: 300502883
Change-Id: I21df914f9ba754921bdc00d8e9a33e77b2606360
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
5bf7b56860 UPSTREAM: mm/damon/sysfs-schemes: implement DAMOS-tried regions clear command
When there are huge number of DAMON regions that specific scheme actions
are tried to be applied, directories and files under 'tried_regions'
scheme directory could waste some memory.  Add another special input
keyword ('clear_schemes_tried_regions') for 'state' file of each kdamond
sysfs directory that can be used for cleanup of the 'tried_regions'
sub-directories.

[sj@kernel.org: skip regions clearing if the scheme directory was removed]
  Link: https://lkml.kernel.org/r/20221114182954.4745-3-sj@kernel.org
Link: https://lkml.kernel.org/r/20221101220328.95765-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 772c15e5adcb32a42dbbcdb905ec49f662312976)

Bug: 300502883
Change-Id: I969e05ce1fa4599bae50454633b61b5320eaa67d
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
80ccab9b0e UPSTREAM: mm/damon/sysfs: implement DAMOS tried regions update command
Implement the code for filling the data of 'tried_regions' DAMON sysfs
directory.  With this commit, DAMON sysfs interface users can write a
special keyword, 'update_schemes_tried_regions' to the corresponding
'state' file of the kdamond.  Then, DAMON sysfs interface will collect the
tried regions information using the 'before_damos_apply()' callback for
one aggregation interval and populate scheme region directories with the
values.

[sj@kernel.org: skip tried regions update if the scheme directory was removed]
  Link: https://lkml.kernel.org/r/20221114182954.4745-2-sj@kernel.org
Link: https://lkml.kernel.org/r/20221101220328.95765-5-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit f1d13cacabe140305844879e495ca67837e059cc)

Bug: 300502883
Change-Id: I6749b8dc75023a9a3f3dc64902196b07fa523267
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
3421250b35 UPSTREAM: mm/damon/sysfs-schemes: implement scheme region directory
Implement region directories under 'tried_regions' directory of each
scheme DAMON sysfs directory.  This directory will provide the address
range, the monitored access frequency ('nr_accesses'), and the age of each
DAMON region that corresponding DAMON-based operation scheme has tried to
be applied.  Note that this commit doesn't implement the code for filling
the data but only the sysfs directory.

Link: https://lkml.kernel.org/r/20221101220328.95765-4-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 9277d0367ba18ef4bb98bafb1209e715844cdf7e)

Bug: 300502883
Change-Id: I69c9010a8fce2fa61a1d27f2964ac7bc7b85dd44
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
b4c34cc168 UPSTREAM: mm/damon/sysfs-schemes: implement schemes/tried_regions directory
For efficient and simple query-like DAMON monitoring results readings and
deep level investigations of DAMOS, DAMON kernel API
(include/linux/damon.h) users can use 'before_damos_apply' DAMON callback.
However, DAMON sysfs interface users don't have such option.

Add a directory, namely 'tried_regions', under each scheme directory to
use it as the interface for the purpose.  Note that this commit is
implementing only the directory but the data filling.

After the data filling change is made, users will be able to signal DAMON
to fill the directory with the regions that corresponding scheme has tried
to be applied.  By setting the access pattern of the scheme, users could
do the efficient query-like monitoring.

Link: https://lkml.kernel.org/r/20221101220328.95765-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 5181b75f438d2e5b7f27bf48c6ea88a87c2882b7)

Bug: 300502883
Change-Id: Idc7a1fca201b90f8fea62899f1e6b500bb8e14e1
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
b5d1f3576b UPSTREAM: mm/damon/core: add a callback for scheme target regions check
Patch series "efficiently expose damos action tried regions information".

DAMON users can retrieve the monitoring results via 'after_aggregation'
callbacks if the user is using the kernel API, or 'damon_aggregated'
tracepoint if the user is in the user space.  Those are useful if full
monitoring results are necessary.  However, if the user has interest in
only a snapshot of the results for some regions having specific access
pattern, the interfaces could be inefficient.  For example, some users
only want to know which memory regions are not accessed for more than a
specific time at the moment.

Also, some DAMOS users would want to know exactly to what memory regions
the schemes' actions tried to be applied, for a debugging or a tuning.  As
DAMOS has its internal mechanism for quota and regions prioritization, the
users would need to simulate DAMOS' mechanism against the monitoring
results.  That's unnecessarily complex.

This patchset implements DAMON kernel API callbacks and sysfs directory
for efficient exposure of the information for the use cases.  The new
callback will be called for each region when a DAMOS action is gonna tried
to be applied to it.  The sysfs directory will be called 'tried_regions'
and placed under each scheme sysfs directory.  Users can write a special
keyworkd, 'update_schemes_regions', to the 'state' file of a kdamond sysfs
directory.  Then, DAMON sysfs interface will fill the directory with the
information of regions that corresponding scheme action was tried to be
applied for next one aggregation interval.

Patches Sequence
----------------

The first one (patch 1) implements the callback for the kernel space
users.  Following two patches (patches 2 and 3) implements sysfs
directories for the information and its sub directories.  Two patches
(patches 4 and 5) for implementing the special keywords for filling the
data to and cleaning up the directories follow.  Patch 6 adds a selftest
for the new sysfs directory.  Finally, two patches (patches 7 and 8)
document the new feature in the administrator guide and the ABI document.

This patch (of 8):

Getting DAMON monitoring results of only specific access pattern (e.g.,
getting address ranges of memory that not accessed at all for two minutes)
can be useful for efficient monitoring of the system.  The information can
also be helpful for deep level investigation of DAMON-based operation
schemes.

For that, users need to record (in case of the user space users) or
iterate (in case of the kernel space users) full monitoring results and
filter it out for the specific access pattern.  In case of the DAMOS
investigation, users will even need to simulate DAMOS' quota and
prioritization mechanisms.  It's inefficient and complex.

Add a new DAMON callback that will be called before each scheme is applied
to each region.  DAMON kernel API users will be able to do the query-like
monitoring results collection, or DAMOS investigation in an efficient and
simple way using it.

Commits for providing the capability to the user space users will follow.

Link: https://lkml.kernel.org/r/20221101220328.95765-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20221101220328.95765-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 44467bbb7e81ebcef2a5bfc9d6546bf7cd015374)

Bug: 300502883
Change-Id: I21ff3c9cf6c30e113f78883e5063bcb898506b41
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
6547a97f32 UPSTREAM: mm/damon/lru_sort: enable and disable synchronously
Writing a value to DAMON_RECLAIM's 'enabled' parameter turns on or off
DAMON in an ansychronous way.  This means the parameter cannot be used to
read the current status of DAMON_RECLAIM.  'kdamond_pid' parameter should
be used instead for the purpose.  The documentation is easy to be read as
it works in a synchronous way, so it is a little bit confusing.  It also
makes the user space tooling dirty.

There's no real reason to have the asynchronous behavior, though.  Simply
make the parameter works synchronously, rather than updating the document.

Link: https://lkml.kernel.org/r/20221025173650.90624-4-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 7a034fbba3361e94956431d17660d7c5674d13c3)

Bug: 300502883
Change-Id: Iaabcbb45e4fe5dfe6781407b23d82657988c53d8
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
540e9b850d UPSTREAM: mm/damon/reclaim: enable and disable synchronously
Patch series "mm/damon/reclaim,lru_sort: enable/disable synchronously".

Writing a value to DAMON_RECLAIM and DAMON_LRU_SORT's 'enabled' parameters
turns on or off DAMON in an ansychronous way.  This means the parameter
cannot be used to read the current status of them.  'kdamond_pid'
parameter should be used instead for the purpose.  The documentation is
easy to be read as it works in a synchronous way, so it is a little bit
confusing.  It also makes the user space tooling dirty.

There's no real reason to have the asynchronous behavior, though.  Simply
make the parameter works synchronously, rather than updating the document.

The first and second patches changes the behavior of the 'enabled'
parameter for DAMON_RECLAIM and adds a selftest for the changed behavior,
respectively.  Following two patches make the same changes for
DAMON_LRU_SORT.

This patch (of 4):

Writing a value to DAMON_RECLAIM's 'enabled' parameter turns on or off
DAMON in an ansychronous way.  This means the parameter cannot be used to
read the current status of DAMON_RECLAIM.  'kdamond_pid' parameter should
be used instead for the purpose.  The documentation is easy to be read as
it works in a synchronous way, so it is a little bit confusing.  It also
makes the user space tooling dirty.

There's no real reason to have the asynchronous behavior, though.  Simply
make the parameter works synchronously, rather than updating the document.

Link: https://lkml.kernel.org/r/20221025173650.90624-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20221025173650.90624-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 04e98764befa371836a78b2b489e8b931a3a9e9a)

Bug: 300502883
Change-Id: If3ea45d1a07d57a3be47317886b17b61f62d5bcf
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
4e2d3f8e31 UPSTREAM: mm/damon/{reclaim,lru_sort}: remove unnecessarily included headers
Some headers that 'reclaim.c' and 'lru_sort.c' are including are
unnecessary now owing to previous cleanups and refactorings.  Remove
those.

Link: https://lkml.kernel.org/r/20221026225943.100429-13-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit b0d3dbd1b98660ec2154fccbd21c13916c967c05)

Bug: 300502883
Change-Id: I66ffcdfe7276261f5de14d8d794a1dd6b5312caf
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
3c0bc73f6e UPSTREAM: mm/damon/modules: deduplicate init steps for DAMON context setup
DAMON_RECLAIM and DAMON_LRU_SORT has duplicated code for DAMON context and
target initializations.  Deduplicate the part by implementing a function
for the initialization in 'modules-common.c' and using it.

Link: https://lkml.kernel.org/r/20221026225943.100429-12-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 7ae2c17f53d5054d1fe5c1a103ad46068034617d)

Bug: 300502883
Change-Id: I3679fce4da1d68f3ba49bb623d1b1b69b0cb6bab
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
67ef7b0f42 UPSTREAM: mm/damon/sysfs: split out schemes directory implementation to separate file
DAMON sysfs interface for 'schemes' directory is implemented using about
one thousand lines of code.  It has no strong dependency with other
parts of its file, so split it out to another file for better code
management.

Link: https://lkml.kernel.org/r/20221026225943.100429-11-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit c8e7b4d0ba348a8ef14956a80c780f152f433764)

Bug: 300502883
Change-Id: I3a8f63dc4f6de6f4662b6f1a7d12afe1e25b36d2
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
0b17df8a4f UPSTREAM: mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new function
'damon_sysfs_schemes_update_stats()' is coupled with both
damon_sysfs_kdamond and damon_sysfs_schemes.  It's a wide range of types
dependency.  It makes splitting the logics a little bit distracting.
Split the function so that each function is coupled with smaller range of
types.

Link: https://lkml.kernel.org/r/20221026225943.100429-10-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 4acd715ff57fd05a481c64d074db68f2cf5711aa)

Bug: 300502883
Change-Id: I3b0ab08f44a5cd0e6ab4dc65f8db8024a26a461e
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
a45dff567c UPSTREAM: mm/damon/sysfs: move unsigned long range directory to common module
The implementation of unsigned long type range directories can be reused
by multiple DAMON sysfs directories including those for DAMON-based
Operation Schemes and the range of number of monitoring regions.  Move the
code into the files for DAMON sysfs common logics.

Link: https://lkml.kernel.org/r/20221026225943.100429-9-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit d332fe11debe69fee3de4c2d84fa0b6649678ad2)

Bug: 300502883
Change-Id: I35f23cb5070fb3fb62a52fd2652e7f054d019201
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
c5038d80ce UPSTREAM: mm/damon/sysfs: move sysfs_lock to common module
DAMON sysfs interface is implemented in a single file, sysfs.c, which has
about 2,800 lines of code.  As the interface is hierarchical and some of
the code can be reused by different hierarchies, it would make more sense
to split out the implementation into common parts and different parts in
multiple files.  As the beginning of the work, create files for common
code and move the global mutex for directories modifications protection
into the new file.

Link: https://lkml.kernel.org/r/20221026225943.100429-8-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 39240595917ec0c4f71d7b9dd7909790715968b5)

Bug: 300502883
Change-Id: I8e0eb32f2b90a907d917f684c35f2a321d944c0e
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
b7fc8d59a5 UPSTREAM: mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc()
'damon_sysfs_region_alloc()' is always called with zero-filled 'struct
damon_addr_range', because the start and end addresses should set by
users.  Remove unnecessary parameters of the function and simplify the
body by using 'kzalloc()'.

Link: https://lkml.kernel.org/r/20221026225943.100429-7-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 1f71981408ef5696ad8544f282d336d4fc60a807)

Bug: 300502883
Change-Id: I6fa54a7474851598fda50a07f5b6b2465bf4cd1f
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
19364f11a4 UPSTREAM: mm/damon/sysfs: use damon_addr_range for region's start and end values
DAMON has a struct for each address range but DAMON sysfs interface is
using the low type (unsigned long) for storing the start and end addresses
of regions.  Use the dedicated struct for better type safety.

Link: https://lkml.kernel.org/r/20221026225943.100429-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 789a230613c8dd14bdd41653de0c22783726276f)

Bug: 300502883
Change-Id: I3bcd00e51144728c7daace32bd1f5283a1ff9e3f
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
b6e6b1dbf8 UPSTREAM: mm/damon/core: split out scheme quota adjustment logic into a new function
DAMOS quota adjustment logic in 'kdamond_apply_schemes()', has some amount
of code, and the logic is not so straightforward.  Split it out to a new
function for better readability.

Link: https://lkml.kernel.org/r/20221026225943.100429-5-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 898810e5ca54691f4e173f5ffc92bbce0335bc69)

Bug: 300502883
Change-Id: I2d13cf290774d36884b533fe703eb01dfc47094c
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
43475d9708 UPSTREAM: mm/damon/core: split out scheme stat update logic into a new function
The function for applying a given DAMON scheme action to a given DAMON
region, 'damos_apply_scheme()' is not quite short.  Make it better to read
by splitting out the stat update logic into a new function.

Link: https://lkml.kernel.org/r/20221026225943.100429-4-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit d1cbbf621fc25950938be74a228ef518d05d93a1)

Bug: 300502883
Change-Id: I1502a102cdd6959494c249b3633ff97af6ccb94c
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
0b0a43029e UPSTREAM: mm/damon/core: split damos application logic into a new function
The DAMOS action applying function, 'damon_do_apply_schemes()', is still
long and not easy to read.  Split out the code for applying a single
action to a single region into a new function for better readability.

Link: https://lkml.kernel.org/r/20221026225943.100429-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit e63a30c51f8400915db401c05d3c4db6743857e8)

Bug: 300502883
Change-Id: Iea228c7ed452fffb72f3d9a94078ad00dabf3269
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
SeongJae Park
6c7495f04a UPSTREAM: mm/damon/core: split out DAMOS-charged region skip logic into a new function
Patch series "mm/damon: cleanup and refactoring code", v2.

This patchset cleans up and refactors a range of DAMON code including the
core, DAMON sysfs interface, and DAMON modules, for better readability and
convenient future feature implementations.

In detail, this patchset splits unnecessarily long and complex functions
in core into smaller functions (patches 1-4).  Then, it cleans up the
DAMON sysfs interface by using more type-safe code (patch 5) and removing
unnecessary function parameters (patch 6).  Further, it refactor the code
by distributing the code into multiple files (patches 7-10).  Last two
patches (patches 11 and 12) deduplicates and remove unnecessary header
inclusion in DAMON modules (reclaim and lru_sort).

This patch (of 12):

The DAMOS action applying function, 'damon_do_apply_schemes()', is quite
long and not so simple.  Split out the already quota-charged region skip
code, which is not a small amount of simple code, into a new function with
some comments for better readability.

Link: https://lkml.kernel.org/r/20221026225943.100429-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20221026225943.100429-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 2ea3498980f5e6f3001f2984b0b92736bf1b78cb)

Bug: 300502883
Change-Id: I416f3c24d8a6e41df5512a8cfee57a9de26ae185
Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
2023-12-16 01:38:42 +00:00
Lee Jones
ac1031618a ANDROID: Snapshot Mainline's version of checkpatch.pl
Nothing fancy here.  Keeping full history is not required.

  `git checkout mainline/master -- scripts/checkpatch.pl`

This may need to be done periodically.

Bug: 316492624
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I4c90b50197ca7277c59e96bf332ecf795c4f3d12
2023-12-15 09:36:46 +00:00
Keir Fraser
4fa87d4d8f ANDROID: KVM: arm64: Skip prefaulting ptes which will be modified later
Block mappings can be split as part of a page table update. When
prefaulting entries during the split, it is pointless to install
valid ptes which will later be modified by the same walk.

At the same time, push the check for pte_is_counted into the
prefault handler, where it logically belongs.

Bug: 308373293
Change-Id: If4599b2860aa62d82ce8db019a8410c2d883de71
Signed-off-by: Keir Fraser <keirf@google.com>
2023-12-15 08:45:53 +00:00
Keir Fraser
fbc707442c ANDROID: KVM: arm64: Introduce module_change_host_prot_range
This allows protection attributes to be changed for a range of
pages via a single module API call.

The original API call modifying a single page is now implemented
as a shim on top of the new range-based call.

The ABI STG is also fixed up:

type 'struct pkvm_module_ops' changed
  member 'union { int(* host_stage2_mod_prot_range)(u64, enum kvm_pgtable_prot, u64); struct { u64 android_kabi_reserved1; }; union { }; }' was added
  member 'u64 android_kabi_reserved1' was removed

Bug: 308373293
Change-Id: I6fbb2e0b325aa972148f48746565dcc10d74edaf
Signed-off-by: Keir Fraser <keirf@google.com>
2023-12-15 08:45:53 +00:00
Keir Fraser
fd720ebc6a ANDROID: KVM: arm64: Relax checks in module_change_host_page_prot
Modules can only relax permissions to RWX. This seems rather arbitrary.
Instead, allow any valid permissions to be set, as long as the page is
a pristine host page, or already module owned.

Bug: 308373293
Change-Id: I905786fad6543f47a00bd9b9f07e17dd660d457c
Signed-off-by: Keir Fraser <keirf@google.com>
2023-12-15 08:45:53 +00:00
Keir Fraser
f082d22541 ANDROID: KVM: arm64: Optimise module_change_host_page_prot
Merge the relaxation and restriction paths to both only need to adjust
permissions. This avoids un-map + re-map on the restriction path; and
avoids installing an annotated entry on the relaxation path (which
will cause a translation fault on first access by the host).

Bug: 308373293
Change-Id: I9c7a6ac149aad64b19a5ce7808334188475b27cc
Signed-off-by: Keir Fraser <keirf@google.com>
2023-12-15 08:45:53 +00:00
Will Deacon
01dd8c280b ANDROID: KVM: arm64: Prefault entries when splitting a block mapping
When splitting a block mapping, we install a table entry pointing to an
empty page and recreate the new entries lazily as we fault them in. For
page-tables with the KVM_PGTABLE_S2_IDMAP flag, this can result in
unnecessary translation faults.

When splitting a block for a page-table with KVM_PGTABLE_S2_IDMAP set,
pre-populate the newly allocate page-table page with contiguous ptes
based on the attributes of the block.

Bug: 308373293
Change-Id: I0c53d048de913e193830caef93d75755270db709
Signed-off-by: Will Deacon <willdeacon@google.com>
Signed-off-by: Keir Fraser <keirf@google.com>
2023-12-15 08:45:53 +00:00
Elliot Berman
cc653d701f ANDROID: virt: gunyah: Zero state_data after vcpu_run
Do not re-use stale state_data on subsequent vcpu runs as the stale data
could be interpreted by Gunyah and rejected.

Bug: 268234781
Change-Id: I3d4bf7a922da1e0e85006ffa58b64a74e320d3c9
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
2023-12-14 15:39:09 -08:00
Benjamin Schwartz
cc294d9503 ANDROID: Update the ABI symbol list
Adding the following symbols:
     - __traceiter_android_vh_ep_create_wakeup_source
     - __traceiter_android_vh_timerfd_create
     - __tracepoint_android_vh_ep_create_wakeup_source
     - __tracepoint_android_vh_timerfd_create

Bug: 155142106

Change-Id: Ie895faefacd62674ac58783ba6a3cd5c3bc46637
Signed-off-by: Benjamin Schwartz <bsschwar@google.com>
2023-12-14 17:32:26 +00:00
Manish Varma
956a0d3998 ANDROID: fs: Add vendor hooks for ep_create_wakeup_source & timerfd_create
timerfd doesn't create any wakelocks, but eventpoll can.  When it does,
it names them after the underlying file descriptor, and since all
timerfd file descriptors are named "[timerfd]" (which saves memory on
systems like desktops with potentially many timerfd instances), all
wakesources created as a result of using the eventpoll-on-timerfd idiom
are called... "[timerfd]".

However, it becomes impossible to tell which "[timerfd]" wakesource is
affliated with which process and hence troubleshooting is difficult.

Adding vendor hooks to allow vendor to assign appropriate names to
timerfd descriptors and eventoll wakesource.

Bug: 155142106

Signed-off-by: Manish Varma <varmam@google.com>
Change-Id: I330a42ab48bed4b26d5eb2f636925c66061165ec
(cherry picked from commit 0ff110fbb309be385126a42ac9f7004ba9b0644e)
2023-12-13 15:54:47 -08:00
DooHyun Hwang
d8d2b95fd0 ANDROID: ABI: update symbol list for galaxy
2 function symbol(s) added
  'int scsi_device_quiesce(struct scsi_device*)'
  'void scsi_device_resume(struct scsi_device*)'

Bug: 316076675
Change-Id: I301b9445f41736ae485c3779b7164962c17117b2
Signed-off-by: DooHyun Hwang <dh0421.hwang@samsung.com>
2023-12-13 17:58:33 +00:00
Greg Kroah-Hartman
fc9e81c1a1 ANDROID: Fix up merge issues in 6.1.64 in net/netfilter/nf_tables_api.c
When merging 6.1.64 into the 'android14-6.1-lts' branch, which contained
a subset of the upstream changes in nf_tables_api.c, the merge got
confused and did it "backwards", backing out some of the needed fixes.
This happens when we cherry-pick a subset of the upstream fixes into the
'android14-6.1' branch and then merge the LTS changes.

Fixes: f1bc13cb9d ("Merge 6.1.64 into android14-6.1-lts")
Change-Id: I8f510160f4ca43a05be265173daccb962531b1b4
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-12-13 15:02:36 +00:00