]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Oct 2021 09:14:24 +0000 (11:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Oct 2021 09:14:24 +0000 (11:14 +0200)
added patches:
libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch
perf-x86-reset-destroy-callback-on-event-init-failure.patch
silence-nfscache-allocation-warnings-with-kvzalloc.patch

queue-5.4/libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch [new file with mode: 0644]
queue-5.4/perf-x86-reset-destroy-callback-on-event-init-failure.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/silence-nfscache-allocation-warnings-with-kvzalloc.patch [new file with mode: 0644]

diff --git a/queue-5.4/libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch b/queue-5.4/libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch
new file mode 100644 (file)
index 0000000..f839dfd
--- /dev/null
@@ -0,0 +1,119 @@
+From 7a8526a5cd51cf5f070310c6c37dd7293334ac49 Mon Sep 17 00:00:00 2001
+From: Kate Hsuan <hpa@redhat.com>
+Date: Fri, 3 Sep 2021 17:44:11 +0800
+Subject: libata: Add ATA_HORKAGE_NO_NCQ_ON_ATI for Samsung 860 and 870 SSD.
+
+From: Kate Hsuan <hpa@redhat.com>
+
+commit 7a8526a5cd51cf5f070310c6c37dd7293334ac49 upstream.
+
+Many users are reporting that the Samsung 860 and 870 SSD are having
+various issues when combined with AMD/ATI (vendor ID 0x1002)  SATA
+controllers and only completely disabling NCQ helps to avoid these
+issues.
+
+Always disabling NCQ for Samsung 860/870 SSDs regardless of the host
+SATA adapter vendor will cause I/O performance degradation with well
+behaved adapters. To limit the performance impact to ATI adapters,
+introduce the ATA_HORKAGE_NO_NCQ_ON_ATI flag to force disable NCQ
+only for these adapters.
+
+Also, two libata.force parameters (noncqati and ncqati) are introduced
+to disable and enable the NCQ for the system which equipped with ATI
+SATA adapter and Samsung 860 and 870 SSDs. The user can determine NCQ
+function to be enabled or disabled according to the demand.
+
+After verifying the chipset from the user reports, the issue appears
+on AMD/ATI SB7x0/SB8x0/SB9x0 SATA Controllers and does not appear on
+recent AMD SATA adapters. The vendor ID of ATI should be 0x1002.
+Therefore, ATA_HORKAGE_NO_NCQ_ON_AMD was modified to
+ATA_HORKAGE_NO_NCQ_ON_ATI.
+
+BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=201693
+Signed-off-by: Kate Hsuan <hpa@redhat.com>
+Reviewed-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20210903094411.58749-1-hpa@redhat.com
+Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Cc: Krzysztof Olędzki <ole@ans.pl>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/ata/libata-core.c |   34 ++++++++++++++++++++++++++++++++--
+ include/linux/libata.h    |    1 +
+ 2 files changed, 33 insertions(+), 2 deletions(-)
+
+--- a/drivers/ata/libata-core.c
++++ b/drivers/ata/libata-core.c
+@@ -2252,6 +2252,25 @@ static void ata_dev_config_ncq_prio(stru
+ }
++static bool ata_dev_check_adapter(struct ata_device *dev,
++                                unsigned short vendor_id)
++{
++      struct pci_dev *pcidev = NULL;
++      struct device *parent_dev = NULL;
++
++      for (parent_dev = dev->tdev.parent; parent_dev != NULL;
++           parent_dev = parent_dev->parent) {
++              if (dev_is_pci(parent_dev)) {
++                      pcidev = to_pci_dev(parent_dev);
++                      if (pcidev->vendor == vendor_id)
++                              return true;
++                      break;
++              }
++      }
++
++      return false;
++}
++
+ static int ata_dev_config_ncq(struct ata_device *dev,
+                              char *desc, size_t desc_sz)
+ {
+@@ -2268,6 +2287,13 @@ static int ata_dev_config_ncq(struct ata
+               snprintf(desc, desc_sz, "NCQ (not used)");
+               return 0;
+       }
++
++      if (dev->horkage & ATA_HORKAGE_NO_NCQ_ON_ATI &&
++          ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI)) {
++              snprintf(desc, desc_sz, "NCQ (not used)");
++              return 0;
++      }
++
+       if (ap->flags & ATA_FLAG_NCQ) {
+               hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE);
+               dev->flags |= ATA_DFLAG_NCQ;
+@@ -4557,9 +4583,11 @@ static const struct ata_blacklist_entry
+       { "Samsung SSD 850*",           NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
+                                               ATA_HORKAGE_ZERO_AFTER_TRIM, },
+       { "Samsung SSD 860*",           NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
+-                                              ATA_HORKAGE_ZERO_AFTER_TRIM, },
++                                              ATA_HORKAGE_ZERO_AFTER_TRIM |
++                                              ATA_HORKAGE_NO_NCQ_ON_ATI, },
+       { "Samsung SSD 870*",           NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
+-                                              ATA_HORKAGE_ZERO_AFTER_TRIM, },
++                                              ATA_HORKAGE_ZERO_AFTER_TRIM |
++                                              ATA_HORKAGE_NO_NCQ_ON_ATI, },
+       { "FCCT*M500*",                 NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
+                                               ATA_HORKAGE_ZERO_AFTER_TRIM, },
+@@ -6916,6 +6944,8 @@ static int __init ata_parse_force_one(ch
+               { "ncq",        .horkage_off    = ATA_HORKAGE_NONCQ },
+               { "noncqtrim",  .horkage_on     = ATA_HORKAGE_NO_NCQ_TRIM },
+               { "ncqtrim",    .horkage_off    = ATA_HORKAGE_NO_NCQ_TRIM },
++              { "noncqati",   .horkage_on     = ATA_HORKAGE_NO_NCQ_ON_ATI },
++              { "ncqati",     .horkage_off    = ATA_HORKAGE_NO_NCQ_ON_ATI },
+               { "dump_id",    .horkage_on     = ATA_HORKAGE_DUMP_ID },
+               { "pio0",       .xfer_mask      = 1 << (ATA_SHIFT_PIO + 0) },
+               { "pio1",       .xfer_mask      = 1 << (ATA_SHIFT_PIO + 1) },
+--- a/include/linux/libata.h
++++ b/include/linux/libata.h
+@@ -423,6 +423,7 @@ enum {
+       ATA_HORKAGE_NOTRIM      = (1 << 24),    /* don't use TRIM */
+       ATA_HORKAGE_MAX_SEC_1024 = (1 << 25),   /* Limit max sects to 1024 */
+       ATA_HORKAGE_MAX_TRIM_128M = (1 << 26),  /* Limit max trim size to 128M */
++      ATA_HORKAGE_NO_NCQ_ON_ATI = (1 << 27),  /* Disable NCQ on ATI chipset */
+        /* DMA mask for user DMA control: User visible values; DO NOT
+           renumber */
diff --git a/queue-5.4/perf-x86-reset-destroy-callback-on-event-init-failure.patch b/queue-5.4/perf-x86-reset-destroy-callback-on-event-init-failure.patch
new file mode 100644 (file)
index 0000000..136bef2
--- /dev/null
@@ -0,0 +1,49 @@
+From 02d029a41dc986e2d5a77ecca45803857b346829 Mon Sep 17 00:00:00 2001
+From: Anand K Mistry <amistry@google.com>
+Date: Wed, 29 Sep 2021 17:04:21 +1000
+Subject: perf/x86: Reset destroy callback on event init failure
+
+From: Anand K Mistry <amistry@google.com>
+
+commit 02d029a41dc986e2d5a77ecca45803857b346829 upstream.
+
+perf_init_event tries multiple init callbacks and does not reset the
+event state between tries. When x86_pmu_event_init runs, it
+unconditionally sets the destroy callback to hw_perf_event_destroy. On
+the next init attempt after x86_pmu_event_init, in perf_try_init_event,
+if the pmu's capabilities includes PERF_PMU_CAP_NO_EXCLUDE, the destroy
+callback will be run. However, if the next init didn't set the destroy
+callback, hw_perf_event_destroy will be run (since the callback wasn't
+reset).
+
+Looking at other pmu init functions, the common pattern is to only set
+the destroy callback on a successful init. Resetting the callback on
+failure tries to replicate that pattern.
+
+This was discovered after commit f11dd0d80555 ("perf/x86/amd/ibs: Extend
+PERF_PMU_CAP_NO_EXCLUDE to IBS Op") when the second (and only second)
+run of the perf tool after a reboot results in 0 samples being
+generated. The extra run of hw_perf_event_destroy results in
+active_events having an extra decrement on each perf run. The second run
+has active_events == 0 and every subsequent run has active_events < 0.
+When active_events == 0, the NMI handler will early-out and not record
+any samples.
+
+Signed-off-by: Anand K Mistry <amistry@google.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Link: https://lkml.kernel.org/r/20210929170405.1.I078b98ee7727f9ae9d6df8262bad7e325e40faf0@changeid
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/events/core.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/x86/events/core.c
++++ b/arch/x86/events/core.c
+@@ -2108,6 +2108,7 @@ static int x86_pmu_event_init(struct per
+       if (err) {
+               if (event->destroy)
+                       event->destroy(event);
++              event->destroy = NULL;
+       }
+       if (READ_ONCE(x86_pmu.attr_rdpmc) &&
index d18270beaffc0fb99b34ef415b017d4cae249a78..796553c17233fe0561a13a67b306fb6e4da28a66 100644 (file)
@@ -11,3 +11,6 @@ scsi-ses-retry-failed-send-receive-diagnostic-comman.patch
 tools-vm-page-types-remove-dependency-on-opt_file-fo.patch
 kvm-do-not-shrink-halt_poll_ns-below-grow_start.patch
 kvm-x86-add-amd-pmu-msrs-to-msrs_to_save_all.patch
+perf-x86-reset-destroy-callback-on-event-init-failure.patch
+silence-nfscache-allocation-warnings-with-kvzalloc.patch
+libata-add-ata_horkage_no_ncq_on_ati-for-samsung-860-and-870-ssd.patch
diff --git a/queue-5.4/silence-nfscache-allocation-warnings-with-kvzalloc.patch b/queue-5.4/silence-nfscache-allocation-warnings-with-kvzalloc.patch
new file mode 100644 (file)
index 0000000..4be70d3
--- /dev/null
@@ -0,0 +1,50 @@
+From 8c38b705b4f4ca4e7f9cc116141bc38391917c30 Mon Sep 17 00:00:00 2001
+From: Rik van Riel <riel@surriel.com>
+Date: Mon, 14 Sep 2020 13:07:19 -0400
+Subject: silence nfscache allocation warnings with kvzalloc
+
+From: Rik van Riel <riel@surriel.com>
+
+commit 8c38b705b4f4ca4e7f9cc116141bc38391917c30 upstream.
+
+silence nfscache allocation warnings with kvzalloc
+
+Currently nfsd_reply_cache_init attempts hash table allocation through
+kmalloc, and manually falls back to vzalloc if that fails. This makes
+the code a little larger than needed, and creates a significant amount
+of serial console spam if you have enough systems.
+
+Switching to kvzalloc gets rid of the allocation warnings, and makes
+the code a little cleaner too as a side effect.
+
+Freeing of nn->drc_hashtbl is already done using kvfree currently.
+
+Signed-off-by: Rik van Riel <riel@surriel.com>
+Signed-off-by: J. Bruce Fields <bfields@redhat.com>
+Cc: Krzysztof Olędzki <ole@ans.pl>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/nfsd/nfscache.c |   12 ++++--------
+ 1 file changed, 4 insertions(+), 8 deletions(-)
+
+--- a/fs/nfsd/nfscache.c
++++ b/fs/nfsd/nfscache.c
+@@ -173,14 +173,10 @@ int nfsd_reply_cache_init(struct nfsd_ne
+       if (status)
+               goto out_nomem;
+-      nn->drc_hashtbl = kcalloc(hashsize,
+-                              sizeof(*nn->drc_hashtbl), GFP_KERNEL);
+-      if (!nn->drc_hashtbl) {
+-              nn->drc_hashtbl = vzalloc(array_size(hashsize,
+-                                               sizeof(*nn->drc_hashtbl)));
+-              if (!nn->drc_hashtbl)
+-                      goto out_shrinker;
+-      }
++      nn->drc_hashtbl = kvzalloc(array_size(hashsize,
++                              sizeof(*nn->drc_hashtbl)), GFP_KERNEL);
++      if (!nn->drc_hashtbl)
++              goto out_shrinker;
+       for (i = 0; i < hashsize; i++) {
+               INIT_LIST_HEAD(&nn->drc_hashtbl[i].lru_head);